aboutsummaryrefslogtreecommitdiff
path: root/src/httpserver.cpp
diff options
context:
space:
mode:
authorJoão Barbosa <joao.paulo.barbosa@gmail.com>2018-11-07 09:08:56 +0000
committerJoão Barbosa <joao.paulo.barbosa@gmail.com>2018-11-23 16:54:22 +0000
commit18e968581697078c36a3c3818f8906cf134ccadd (patch)
tree7d35027438359b4d24581257c408eb2c35db89c2 /src/httpserver.cpp
parent02e1e4eff6cda0bfc24b455a7c1583394cbff6eb (diff)
http: Send "Connection: close" header if shutdown is requested
Sending the header "Connection: close" makes libevent close persistent connections (implicit with HTTP 1.1) which cleans the event base when shutdown is requested.
Diffstat (limited to 'src/httpserver.cpp')
-rw-r--r--src/httpserver.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/httpserver.cpp b/src/httpserver.cpp
index 00434169cd..342956f7a3 100644
--- a/src/httpserver.cpp
+++ b/src/httpserver.cpp
@@ -10,6 +10,7 @@
#include <util/strencodings.h>
#include <netbase.h>
#include <rpc/protocol.h> // For HTTP status codes
+#include <shutdown.h>
#include <sync.h>
#include <ui_interface.h>
@@ -583,6 +584,9 @@ void HTTPRequest::WriteHeader(const std::string& hdr, const std::string& value)
void HTTPRequest::WriteReply(int nStatus, const std::string& strReply)
{
assert(!replySent && req);
+ if (ShutdownRequested()) {
+ WriteHeader("Connection", "close");
+ }
// Send event to main http thread to send reply message
struct evbuffer* evb = evhttp_request_get_output_buffer(req);
assert(evb);