From eb4c60877e1030c6f52b2d9a50df5bb3d44d83ce Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Tue, 2 Mar 2021 21:02:17 +0200 Subject: [PATCH] vweb: fix timeouting after 30 seconds, when a request with `Content-Length: 0` was processed --- vlib/vweb/request.v | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/vlib/vweb/request.v b/vlib/vweb/request.v index ee29657bad..3cbfb656f9 100644 --- a/vlib/vweb/request.v +++ b/vlib/vweb/request.v @@ -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 } }