Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions proxy/ProxyTransaction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,11 @@ ProxyTransaction::allow_half_open() const
{
return false;
}

// Most protocols will not want to set the Connection: header
// For H2 it will initiate the drain logic. So we make do nothing
// the default action.
Comment thread
masaori335 marked this conversation as resolved.
void
ProxyTransaction::set_close_connection(HTTPHdr &hdr) const
{
}
4 changes: 4 additions & 0 deletions proxy/ProxyTransaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ class ProxyTransaction : public VConnection
// Returns true if there is a request body for this request
virtual bool has_request_body(int64_t content_length, bool is_chunked_set) const;

// Worker function to set Connection:close header if appropriate for
// underlying protocol
virtual void set_close_connection(HTTPHdr &hdr) const;

sockaddr const *get_remote_addr() const;

virtual HTTPVersion get_version(HTTPHdr &hdr) const;
Expand Down
7 changes: 7 additions & 0 deletions proxy/http/Http1Transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Http1Transaction : public ProxyTransaction
// Methods
int get_transaction_id() const override;
void set_reader(IOBufferReader *reader);
void set_close_connection(HTTPHdr &hdr) const override;

////////////////////
// Variables
Expand Down Expand Up @@ -71,3 +72,9 @@ Http1Transaction::set_reader(IOBufferReader *reader)
{
_reader = reader;
}

inline void
Http1Transaction::set_close_connection(HTTPHdr &hdr) const
{
hdr.value_set(MIME_FIELD_CONNECTION, MIME_LEN_CONNECTION, "close", 5);
}
2 changes: 1 addition & 1 deletion proxy/http/HttpSM.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5872,7 +5872,7 @@ HttpSM::do_drain_request_body(HTTPHdr &response)

close_connection:
t_state.client_info.keep_alive = HTTP_NO_KEEPALIVE;
response.value_set(MIME_FIELD_CONNECTION, MIME_LEN_CONNECTION, "close", 5);
ua_txn->set_close_connection(response);
}

void
Expand Down
11 changes: 9 additions & 2 deletions proxy/http/HttpTransact.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6891,7 +6891,10 @@ HttpTransact::handle_request_keep_alive_headers(State *s, HTTPVersion ver, HTTPH
if (s->current.request_to == PARENT_PROXY && parent_is_proxy(s)) {
heads->value_set(MIME_FIELD_PROXY_CONNECTION, MIME_LEN_PROXY_CONNECTION, "close", 5);
} else {
heads->value_set(MIME_FIELD_CONNECTION, MIME_LEN_CONNECTION, "close", 5);
ProxyTransaction *svr = s->state_machine->get_server_txn();
if (svr) {
svr->set_close_connection(*heads);
}
}
}
// Note: if we are 1.1, we always need to send the close
Expand Down Expand Up @@ -7050,7 +7053,11 @@ HttpTransact::handle_response_keep_alive_headers(State *s, HTTPVersion ver, HTTP
case KA_CLOSE:
case KA_DISABLED:
if (s->client_info.keep_alive != HTTP_NO_KEEPALIVE || (ver == HTTP_1_1)) {
heads->value_set(c_hdr_field_str, c_hdr_field_len, "close", 5);
if (s->client_info.proxy_connect_hdr) {
Comment thread
masaori335 marked this conversation as resolved.
heads->value_set(c_hdr_field_str, c_hdr_field_len, "close", 5);
} else if (s->state_machine->ua_txn != nullptr) {
s->state_machine->ua_txn->set_close_connection(*heads);
}
s->client_info.keep_alive = HTTP_NO_KEEPALIVE;
}
// Note: if we are 1.1, we always need to send the close
Expand Down