From: Waldemar Kozaczuk <[email protected]> Committer: Waldemar Kozaczuk <[email protected]> Branch: master
httpserver: properly handle chunked POST requests with body This bug was discovered when running httpserver unit tests with python scripts upgraded to version 3. The new version of the requests module chunks POST requests with body so that they are sent over socket in two parts - the request and the body. Our httpserver had a bug in how it consumed such requests. Instead of completing the request once the body chunk was fully received, it would try to re-consume the same body chunk as next request and after failing to, it would send back a 400 (bad request) response. So this patch simply changes the connection logic to complete handling request in such scenario and proceed to the next request. Signed-off-by: Waldemar Kozaczuk <[email protected]> --- diff --git a/modules/httpserver-api/connection.cc b/modules/httpserver-api/connection.cc --- a/modules/httpserver-api/connection.cc +++ b/modules/httpserver-api/connection.cc @@ -246,8 +246,11 @@ void connection::do_read() request_.content.append(buffer_.data(), buffer_.data() + bytes_transferred); if (request_.content.size() < request_.content_length) { do_read(); - return; + } else { + request_handler_.handle_request(request_, reply_); + do_write(); } + return; } auto r = request_parser_.parse( -- You received this message because you are subscribed to the Google Groups "OSv Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/osv-dev/000000000000857149059f19e3ee%40google.com.
