Commit 84832258 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

nghttpx: Don't rewrite host for CONNECT method

parent 585af938
......@@ -619,7 +619,7 @@ void Downstream::rewrite_location_response_header(
return;
}
std::string new_uri;
if (get_config()->no_host_rewrite) {
if (get_config()->no_host_rewrite || request_method_ == "CONNECT") {
if (!request_http2_authority_.empty()) {
new_uri = http2::rewrite_location_uri(
(*hd).value, u, request_http2_authority_, request_http2_authority_,
......
......@@ -253,9 +253,13 @@ int Http2DownstreamConnection::push_request_headers() {
downstream_->set_request_pending(false);
auto no_host_rewrite = get_config()->no_host_rewrite ||
get_config()->http2_proxy ||
get_config()->client_proxy ||
downstream_->get_request_method() == "CONNECT";
const char *authority = nullptr, *host = nullptr;
if (!get_config()->no_host_rewrite && !get_config()->http2_proxy &&
!get_config()->client_proxy) {
if (!no_host_rewrite) {
// HTTP/2 backend does not support multiple address, so we always
// use index = 0.
if (!downstream_->get_request_http2_authority().empty()) {
......@@ -369,8 +373,7 @@ int Http2DownstreamConnection::push_request_headers() {
nva.push_back(http2::make_nv_ls(":path", path));
}
if (!get_config()->no_host_rewrite && !get_config()->http2_proxy &&
!get_config()->client_proxy) {
if (!no_host_rewrite) {
if (authority) {
nva.push_back(http2::make_nv_lc(":authority", authority));
}
......
......@@ -212,7 +212,8 @@ int HttpDownstreamConnection::attach_downstream(Downstream *downstream) {
int HttpDownstreamConnection::push_request_headers() {
const char *authority = nullptr, *host = nullptr;
if (!get_config()->no_host_rewrite && !get_config()->http2_proxy &&
!get_config()->client_proxy) {
!get_config()->client_proxy &&
downstream_->get_request_method() != "CONNECT") {
if (!downstream_->get_request_http2_authority().empty()) {
authority = get_config()->downstream_addrs[addr_idx_].hostport.get();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment