mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 10:38:42 +01:00
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.
This commit is contained in:
parent
02e1e4eff6
commit
18e9685816
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user