From 1c43cdbbc89fd5b004e3ce701fe81c62c2045e67 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 28 Dec 2013 17:02:43 +0900 Subject: [PATCH] nghttpx: Don't rewrite location if proxy mode is used --- src/shrpx_http2_upstream.cc | 6 ++++-- src/shrpx_https_upstream.cc | 6 ++++-- src/shrpx_spdy_upstream.cc | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/shrpx_http2_upstream.cc b/src/shrpx_http2_upstream.cc index 5b16e919..2f5ca110 100644 --- a/src/shrpx_http2_upstream.cc +++ b/src/shrpx_http2_upstream.cc @@ -945,8 +945,10 @@ int Http2Upstream::on_downstream_header_complete(Downstream *downstream) DLOG(INFO, downstream) << "HTTP response header completed"; } downstream->normalize_response_headers(); - downstream->rewrite_norm_location_response_header - (get_client_handler()->get_upstream_scheme(), get_config()->port); + if(!get_config()->http2_proxy && !get_config()->client_proxy) { + downstream->rewrite_norm_location_response_header + (get_client_handler()->get_upstream_scheme(), get_config()->port); + } downstream->concat_norm_response_headers(); auto end_headers = std::end(downstream->get_response_headers()); size_t nheader = downstream->get_response_headers().size(); diff --git a/src/shrpx_https_upstream.cc b/src/shrpx_https_upstream.cc index 4e8895d6..2bd0a4ee 100644 --- a/src/shrpx_https_upstream.cc +++ b/src/shrpx_https_upstream.cc @@ -656,8 +656,10 @@ int HttpsUpstream::on_downstream_header_complete(Downstream *downstream) hdrs += http2::get_status_string(downstream->get_response_http_status()); hdrs += "\r\n"; downstream->normalize_response_headers(); - downstream->rewrite_norm_location_response_header - (get_client_handler()->get_upstream_scheme(), get_config()->port); + if(!get_config()->http2_proxy && !get_config()->client_proxy) { + downstream->rewrite_norm_location_response_header + (get_client_handler()->get_upstream_scheme(), get_config()->port); + } auto end_headers = std::end(downstream->get_response_headers()); http2::build_http1_headers_from_norm_headers (hdrs, downstream->get_response_headers()); diff --git a/src/shrpx_spdy_upstream.cc b/src/shrpx_spdy_upstream.cc index eab13310..ef30550d 100644 --- a/src/shrpx_spdy_upstream.cc +++ b/src/shrpx_spdy_upstream.cc @@ -840,8 +840,10 @@ int SpdyUpstream::on_downstream_header_complete(Downstream *downstream) DLOG(INFO, downstream) << "HTTP response header completed"; } downstream->normalize_response_headers(); - downstream->rewrite_norm_location_response_header - (get_client_handler()->get_upstream_scheme(), get_config()->port); + if(!get_config()->http2_proxy && !get_config()->client_proxy) { + downstream->rewrite_norm_location_response_header + (get_client_handler()->get_upstream_scheme(), get_config()->port); + } size_t nheader = downstream->get_response_headers().size(); // 6 means :status, :version and possible via header field. auto nv = util::make_unique(nheader * 2 + 6 + 1);