From 04ced3b95438f3ea33476c0d35fc59c3a5ab5bcd Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Mon, 26 Feb 2018 20:25:27 -0800 Subject: [PATCH] Examples clear the HTTP message before reading fix #1043 --- CHANGELOG.md | 6 ++++++ doc/qbk/09_releases.qbk | 2 ++ example/advanced/server-flex/advanced_server_flex.cpp | 4 ++++ example/advanced/server/advanced_server.cpp | 4 ++++ example/http/server/async-ssl/http_server_async_ssl.cpp | 4 ++++ example/http/server/async/http_server_async.cpp | 4 ++++ .../http/server/stackless-ssl/http_server_stackless_ssl.cpp | 4 ++++ example/http/server/stackless/http_server_stackless.cpp | 4 ++++ 8 files changed, 32 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 66a05f37..6d72aa3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +Version 160: + +* Examples clear the HTTP message before reading + +-------------------------------------------------------------------------------- + Version 159: * Fix typo in release notes diff --git a/doc/qbk/09_releases.qbk b/doc/qbk/09_releases.qbk index 54813141..fa23865f 100644 --- a/doc/qbk/09_releases.qbk +++ b/doc/qbk/09_releases.qbk @@ -114,6 +114,8 @@ to update to the latest Boost release. * Safe treatment of zero-length string arguments in basic_fields +* ([issue 1043]) Examples clear the HTTP message before reading + [*API Changes] * Remove unintended public members of diff --git a/example/advanced/server-flex/advanced_server_flex.cpp b/example/advanced/server-flex/advanced_server_flex.cpp index 4bb04685..b1f4ef71 100644 --- a/example/advanced/server-flex/advanced_server_flex.cpp +++ b/example/advanced/server-flex/advanced_server_flex.cpp @@ -787,6 +787,10 @@ public: // Set the timer timer_.expires_after(std::chrono::seconds(15)); + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; + // Read a request http::async_read( derived().stream(), diff --git a/example/advanced/server/advanced_server.cpp b/example/advanced/server/advanced_server.cpp index b3d91b3d..d814cb48 100644 --- a/example/advanced/server/advanced_server.cpp +++ b/example/advanced/server/advanced_server.cpp @@ -591,6 +591,10 @@ public: // Set the timer timer_.expires_after(std::chrono::seconds(15)); + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; + // Read a request http::async_read(socket_, buffer_, req_, boost::asio::bind_executor( diff --git a/example/http/server/async-ssl/http_server_async_ssl.cpp b/example/http/server/async-ssl/http_server_async_ssl.cpp index 4df2cce2..9c767152 100644 --- a/example/http/server/async-ssl/http_server_async_ssl.cpp +++ b/example/http/server/async-ssl/http_server_async_ssl.cpp @@ -311,6 +311,10 @@ public: void do_read() { + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; + // Read a request http::async_read(stream_, buffer_, req_, boost::asio::bind_executor( diff --git a/example/http/server/async/http_server_async.cpp b/example/http/server/async/http_server_async.cpp index d596f046..33177599 100644 --- a/example/http/server/async/http_server_async.cpp +++ b/example/http/server/async/http_server_async.cpp @@ -287,6 +287,10 @@ public: void do_read() { + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; + // Read a request http::async_read(socket_, buffer_, req_, boost::asio::bind_executor( diff --git a/example/http/server/stackless-ssl/http_server_stackless_ssl.cpp b/example/http/server/stackless-ssl/http_server_stackless_ssl.cpp index 0243ad53..a0fbac4e 100644 --- a/example/http/server/stackless-ssl/http_server_stackless_ssl.cpp +++ b/example/http/server/stackless-ssl/http_server_stackless_ssl.cpp @@ -320,6 +320,10 @@ public: for(;;) { + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; + // Read a request yield http::async_read(stream_, buffer_, req_, boost::asio::bind_executor( diff --git a/example/http/server/stackless/http_server_stackless.cpp b/example/http/server/stackless/http_server_stackless.cpp index c0bf0f7c..e92d0ad2 100644 --- a/example/http/server/stackless/http_server_stackless.cpp +++ b/example/http/server/stackless/http_server_stackless.cpp @@ -300,6 +300,10 @@ public: { for(;;) { + // Make the request empty before reading, + // otherwise the operation behavior is undefined. + req_ = {}; + // Read a request yield http::async_read(socket_, buffer_, req_, boost::asio::bind_executor(