From 0209b7c083407df6a8628ed4af78eefb3ed511b2 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Wed, 27 Aug 2014 21:25:25 +0900 Subject: [PATCH] nghttpx: Fix location rewrite is failed because request headers are empty Previously we empties request headers after they are sent to downstream in order to free memory. But it turns out that we use request headers when rewriting location header response field. Also user reported that request headers are useful to add new features. This commits defers the deletion of request headers to the point when response headers are deleted (which is after response headers are sent to upstream client). --- src/shrpx_http2_downstream_connection.cc | 1 - src/shrpx_http2_upstream.cc | 1 + src/shrpx_http_downstream_connection.cc | 2 -- src/shrpx_https_upstream.cc | 1 + src/shrpx_spdy_upstream.cc | 1 + 5 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/shrpx_http2_downstream_connection.cc b/src/shrpx_http2_downstream_connection.cc index 24471025..99a3528b 100644 --- a/src/shrpx_http2_downstream_connection.cc +++ b/src/shrpx_http2_downstream_connection.cc @@ -466,7 +466,6 @@ int Http2DownstreamConnection::push_request_headers() return -1; } - downstream_->clear_request_headers(); downstream_->reset_downstream_wtimer(); http2session_->notify(); diff --git a/src/shrpx_http2_upstream.cc b/src/shrpx_http2_upstream.cc index 4a1be731..62541efe 100644 --- a/src/shrpx_http2_upstream.cc +++ b/src/shrpx_http2_upstream.cc @@ -1306,6 +1306,7 @@ int Http2Upstream::on_downstream_header_complete(Downstream *downstream) } downstream->clear_response_headers(); + downstream->clear_request_headers(); return 0; } diff --git a/src/shrpx_http_downstream_connection.cc b/src/shrpx_http_downstream_connection.cc index 1c2bb055..d70ab25f 100644 --- a/src/shrpx_http_downstream_connection.cc +++ b/src/shrpx_http_downstream_connection.cc @@ -297,8 +297,6 @@ int HttpDownstreamConnection::push_request_headers() &get_config()->downstream_read_timeout, &get_config()->downstream_write_timeout); - downstream_->clear_request_headers(); - return 0; } diff --git a/src/shrpx_https_upstream.cc b/src/shrpx_https_upstream.cc index ee8a9177..26ebf1aa 100644 --- a/src/shrpx_https_upstream.cc +++ b/src/shrpx_https_upstream.cc @@ -877,6 +877,7 @@ int HttpsUpstream::on_downstream_header_complete(Downstream *downstream) } downstream->clear_response_headers(); + downstream->clear_request_headers(); return 0; } diff --git a/src/shrpx_spdy_upstream.cc b/src/shrpx_spdy_upstream.cc index 4c0d9b79..bfe76278 100644 --- a/src/shrpx_spdy_upstream.cc +++ b/src/shrpx_spdy_upstream.cc @@ -1013,6 +1013,7 @@ int SpdyUpstream::on_downstream_header_complete(Downstream *downstream) } downstream->clear_response_headers(); + downstream->clear_request_headers(); return 0; }