1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

picoev: make compile, add header parsing

This commit is contained in:
Sumeet Chhetri
2020-06-07 04:53:30 +05:30
committed by GitHub
parent d62d0c40d2
commit 442030a7c8
6 changed files with 41 additions and 17 deletions

View File

@@ -4,15 +4,16 @@ pub struct Request {
pub mut:
method string
path string
headers &C.phr_header_t
headers[100] C.phr_header
num_headers u64
body string
}
[inline]
pub fn (mut r Request) parse_request(s string, headers &C.phr_header_t, max_headers int) int {
pub fn (mut r Request) parse_request(s string, max_headers int) int {
method_len := u64(0)
path_len := u64(0)
minor_version := 0
@@ -23,13 +24,12 @@ pub fn (mut r Request) parse_request(s string, headers &C.phr_header_t, max_head
&r.method, &method_len,
&r.path, &path_len,
&minor_version,
headers, &num_headers,
r.headers, &num_headers,
0
)
if pret > 0 {
r.method = tos(r.method.str, int(method_len))
r.path = tos(r.path.str, int(path_len))
r.headers = headers
r.num_headers = num_headers
}
return pret

View File

@@ -88,7 +88,7 @@ pub fn (mut r Response) raw(response string) {
[inline]
pub fn (mut r Response) end() int {
n := int(r.buf - r.buf_start)
n := int(r.buf) - int(r.buf_start)
if C.write(r.fd, r.buf_start, n) != n {
return -1
}