vweb: fix timeouting after 30 seconds, when a request with `Content-Length: 0` was processed

pull/9069/head
Delyan Angelov 2021-03-02 21:02:17 +02:00
parent 488848e904
commit eb4c60877e
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
1 changed files with 6 additions and 5 deletions

View File

@ -29,12 +29,13 @@ pub fn parse_request(mut reader io.BufferedReader) ?http.Request {
}
// body
mut body := [byte(0)]
mut body := []byte{}
if length := h.get(.content_length) {
n := length.int()
body = []byte{len: n, cap: n + 1}
reader.read(mut body) or { }
body << 0
if n > 0 {
body = []byte{len: n}
reader.read(mut body) or { }
}
}
return http.Request{
@ -42,7 +43,7 @@ pub fn parse_request(mut reader io.BufferedReader) ?http.Request {
url: target.str()
headers: headers
lheaders: lheaders
data: string(body)
data: body.bytestr()
version: version
}
}