mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-08-29 09:45:35 +02: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:
@@ -10,6 +10,7 @@
|
|||||||
#include <util/strencodings.h>
|
#include <util/strencodings.h>
|
||||||
#include <netbase.h>
|
#include <netbase.h>
|
||||||
#include <rpc/protocol.h> // For HTTP status codes
|
#include <rpc/protocol.h> // For HTTP status codes
|
||||||
|
#include <shutdown.h>
|
||||||
#include <sync.h>
|
#include <sync.h>
|
||||||
#include <ui_interface.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)
|
void HTTPRequest::WriteReply(int nStatus, const std::string& strReply)
|
||||||
{
|
{
|
||||||
assert(!replySent && req);
|
assert(!replySent && req);
|
||||||
|
if (ShutdownRequested()) {
|
||||||
|
WriteHeader("Connection", "close");
|
||||||
|
}
|
||||||
// Send event to main http thread to send reply message
|
// Send event to main http thread to send reply message
|
||||||
struct evbuffer* evb = evhttp_request_get_output_buffer(req);
|
struct evbuffer* evb = evhttp_request_get_output_buffer(req);
|
||||||
assert(evb);
|
assert(evb);
|
||||||
|
Reference in New Issue
Block a user