diff options
author | 2017-02-05 18:32:46 +0100 | |
---|---|---|
committer | 2017-02-05 18:32:46 +0100 | |
commit | 90c14be17416d8699a29cfea3c2480b1c453637b (patch) | |
tree | 054b5b175f94730b433a71498661580654659f1f /src/lib/util/server_http.hpp | |
parent | 70051f6c1f009bae411d68a8afa229259504e866 (diff) |
Sync with upstream (nw)
Diffstat (limited to 'src/lib/util/server_http.hpp')
-rw-r--r-- | src/lib/util/server_http.hpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/lib/util/server_http.hpp b/src/lib/util/server_http.hpp index 57fd57e6993..978e9e3ce40 100644 --- a/src/lib/util/server_http.hpp +++ b/src/lib/util/server_http.hpp @@ -89,6 +89,12 @@ namespace webpp { void send(std::string str) { m_ostream << m_header.str() << "Content-Length: " << str.length() << "\r\n\r\n" << str; } size_t size() const { return m_streambuf.size(); } std::shared_ptr<socket_type> socket() { return m_socket; } + + /// If true, force server to close the connection after the response have been sent. + /// + /// This is useful when implementing a HTTP/1.0-server sending content + /// without specifying the content length. + bool close_connection_after_response = false; }; class Content : public std::istream { @@ -182,7 +188,7 @@ namespace webpp { void remove_handler(std::string regex) { std::lock_guard<std::mutex> lock(m_resource_mutex); - for (auto &it = m_resource.begin(); it != m_resource.end(); ++it) + for (auto it = m_resource.begin(); it != m_resource.end(); ++it) { if (it->first.getstr() == regex) { @@ -428,6 +434,9 @@ namespace webpp { return; } + if (response->close_connection_after_response) + return; + auto range = request->header.equal_range("Connection"); case_insensitive_equals check; for (auto it = range.first; it != range.second; ++it) { |