From faf3c68c4bef8ed34ce60d75265f52dc521097c5 Mon Sep 17 00:00:00 2001 From: eidheim Date: Wed, 9 Dec 2015 14:44:28 +0100 Subject: [PATCH] Fixes #28 --- server_http.hpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/server_http.hpp b/server_http.hpp index c7ae79fe..47e19638 100644 --- a/server_http.hpp +++ b/server_http.hpp @@ -249,15 +249,22 @@ namespace SimpleWeb { catch(const std::exception &e) { return; } - boost::asio::async_read(*socket, request->streambuf, - boost::asio::transfer_exactly(content_length-num_additional_bytes), - [this, socket, request, timer] - (const boost::system::error_code& ec, size_t /*bytes_transferred*/) { + if(content_length>num_additional_bytes) { + boost::asio::async_read(*socket, request->streambuf, + boost::asio::transfer_exactly(content_length-num_additional_bytes), + [this, socket, request, timer] + (const boost::system::error_code& ec, size_t /*bytes_transferred*/) { + if(timeout_content>0) + timer->cancel(); + if(!ec) + find_resource(socket, request); + }); + } + else { if(timeout_content>0) timer->cancel(); - if(!ec) - find_resource(socket, request); - }); + find_resource(socket, request); + } } else { find_resource(socket, request);