mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
pico: small refactor (#9857)
This commit is contained in:

committed by
GitHub

parent
8ccdae6188
commit
dee4904bee
@@ -1,6 +1,8 @@
|
||||
module picohttpparser
|
||||
|
||||
pub struct Request {
|
||||
mut:
|
||||
prev_len int
|
||||
pub mut:
|
||||
method string
|
||||
path string
|
||||
@@ -17,7 +19,7 @@ pub fn (mut r Request) parse_request(s string, max_headers int) int {
|
||||
num_headers := size_t(max_headers)
|
||||
|
||||
pret := C.phr_parse_request(s.str, s.len, PPchar(&r.method.str), &method_len, PPchar(&r.path.str),
|
||||
&path_len, &minor_version, &r.headers[0], &num_headers, 0)
|
||||
&path_len, &minor_version, &r.headers[0], &num_headers, r.prev_len)
|
||||
if pret > 0 {
|
||||
unsafe {
|
||||
r.method = tos(r.method.str, int(method_len))
|
||||
@@ -25,6 +27,7 @@ pub fn (mut r Request) parse_request(s string, max_headers int) int {
|
||||
}
|
||||
r.num_headers = u64(num_headers)
|
||||
}
|
||||
r.prev_len = s.len
|
||||
return pret
|
||||
}
|
||||
|
||||
|
@@ -10,13 +10,7 @@ pub mut:
|
||||
}
|
||||
|
||||
[inline]
|
||||
[deprecated: 'use Response.write_string() instead']
|
||||
pub fn (mut r Response) write_str(s string) {
|
||||
r.write_string(s)
|
||||
}
|
||||
|
||||
[inline]
|
||||
fn (mut r Response) write_string(s string) {
|
||||
pub fn (mut r Response) write_string(s string) {
|
||||
unsafe {
|
||||
C.memcpy(r.buf, s.str, s.len)
|
||||
r.buf += s.len
|
||||
|
Reference in New Issue
Block a user