From 96489f2650a854b2fec513c1bf430986c715a87c Mon Sep 17 00:00:00 2001 From: Ognjen Sobajic Date: Fri, 11 Oct 2013 11:06:07 -0700 Subject: [PATCH] Fixing the issue with handshake_fail when the test would crash occasionally. --- Release/include/cpprest/http_linux_server.h | 4 ++-- .../src/http/listener/http_linux_server.cpp | 23 +++++++++---------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/Release/include/cpprest/http_linux_server.h b/Release/include/cpprest/http_linux_server.h index 390ff96069..1b8cd33d80 100644 --- a/Release/include/cpprest/http_linux_server.h +++ b/Release/include/cpprest/http_linux_server.h @@ -96,11 +96,11 @@ class connection void handle_chunked_body(const boost::system::error_code& ec, int toWrite); void dispatch_request_to_listener(); void request_data_avail(size_t size); - void do_response(bool bad_reqiest=false); + void do_response(bool bad_request=false); template void async_read_until_buffersize(size_t size, ReadHandler handler); void async_process_response(http_response response); - void cancel_sending_response_with_error(http_response response, std::exception_ptr); + void cancel_sending_response_with_error(http_response response, std::exception_ptr); void handle_headers_written(http_response response, const boost::system::error_code& ec); void handle_write_large_response(http_response response, const boost::system::error_code& ec); void handle_write_chunked_response(http_response response, const boost::system::error_code& ec); diff --git a/Release/src/http/listener/http_linux_server.cpp b/Release/src/http/listener/http_linux_server.cpp index 8144760caf..47eb7f1285 100644 --- a/Release/src/http/listener/http_linux_server.cpp +++ b/Release/src/http/listener/http_linux_server.cpp @@ -140,13 +140,12 @@ void connection::handle_http_line(const boost::system::error_code& ec) else if (boost::iequals(http_verb, http::methods::CONNECT)) http_verb = http::methods::CONNECT; else if (boost::iequals(http_verb, http::methods::OPTIONS)) http_verb = http::methods::OPTIONS; - // Check to see if there is not allowed character on the input - + // Check to see if there is not allowed character on the input if (!web::http::details::validate_method(http_verb)) { m_request.reply(status_codes::BadRequest); + m_close = true; do_response(true); - finish_request_response(); return; } @@ -443,15 +442,15 @@ void connection::do_response(bool bad_request) } // before sending response, the full incoming message need to be processed. if (bad_request) - { - async_process_response(response); - } - else - { - m_request.content_ready().then([=](pplx::task) { - async_process_response(response); - }); - } + { + async_process_response(response); + } + else + { + m_request.content_ready().then([=](pplx::task) { + async_process_response(response); + }); + } }); }