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( ...@@ -619,7 +619,7 @@ void Downstream::rewrite_location_response_header(
return; return;
} }
std::string new_uri; std::string new_uri;
if (get_config()->no_host_rewrite) { if (get_config()->no_host_rewrite || request_method_ == "CONNECT") {
if (!request_http2_authority_.empty()) { if (!request_http2_authority_.empty()) {
new_uri = http2::rewrite_location_uri( new_uri = http2::rewrite_location_uri(
(*hd).value, u, request_http2_authority_, request_http2_authority_, (*hd).value, u, request_http2_authority_, request_http2_authority_,
......
...@@ -253,9 +253,13 @@ int Http2DownstreamConnection::push_request_headers() { ...@@ -253,9 +253,13 @@ int Http2DownstreamConnection::push_request_headers() {
downstream_->set_request_pending(false); 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; const char *authority = nullptr, *host = nullptr;
if (!get_config()->no_host_rewrite && !get_config()->http2_proxy && if (!no_host_rewrite) {
!get_config()->client_proxy) {
// HTTP/2 backend does not support multiple address, so we always // HTTP/2 backend does not support multiple address, so we always
// use index = 0. // use index = 0.
if (!downstream_->get_request_http2_authority().empty()) { if (!downstream_->get_request_http2_authority().empty()) {
...@@ -369,8 +373,7 @@ int Http2DownstreamConnection::push_request_headers() { ...@@ -369,8 +373,7 @@ int Http2DownstreamConnection::push_request_headers() {
nva.push_back(http2::make_nv_ls(":path", path)); nva.push_back(http2::make_nv_ls(":path", path));
} }
if (!get_config()->no_host_rewrite && !get_config()->http2_proxy && if (!no_host_rewrite) {
!get_config()->client_proxy) {
if (authority) { if (authority) {
nva.push_back(http2::make_nv_lc(":authority", authority)); nva.push_back(http2::make_nv_lc(":authority", authority));
} }
......
...@@ -212,7 +212,8 @@ int HttpDownstreamConnection::attach_downstream(Downstream *downstream) { ...@@ -212,7 +212,8 @@ int HttpDownstreamConnection::attach_downstream(Downstream *downstream) {
int HttpDownstreamConnection::push_request_headers() { int HttpDownstreamConnection::push_request_headers() {
const char *authority = nullptr, *host = nullptr; const char *authority = nullptr, *host = nullptr;
if (!get_config()->no_host_rewrite && !get_config()->http2_proxy && 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()) { if (!downstream_->get_request_http2_authority().empty()) {
authority = get_config()->downstream_addrs[addr_idx_].hostport.get(); 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