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
1 changed files with 4 additions and 0 deletions
|
@ -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…
Add table
Reference in a new issue