Skip to content
This repository was archived by the owner on Apr 10, 2025. It is now read-only.

Commit 059dd20

Browse files
committed
reapply: location-header: tweak location header handling
- Fix potentially sending the location header into PSOL twice. - Be more thorough when unsetting the location header Attempts to fix #725 from oschaaf
1 parent 56a5d41 commit 059dd20

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/ngx_pagespeed.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,12 @@ ngx_int_t ps_base_fetch_handler(ngx_http_request_t* r) {
302302
STR_CASE_EQ_LITERAL(header->key, "Last-Modified") ||
303303
STR_CASE_EQ_LITERAL(header->key, "Expires"))))) {
304304
header->hash = 0;
305+
if (STR_CASE_EQ_LITERAL(header->key, "Location")) {
306+
// There's a possible issue with the location header, where setting
307+
// the hash to 0 is not enough. See:
308+
// https://github.com/nginx/nginx/blob/master/src/http/ngx_http_header_filter_module.c#L314
309+
r->headers_out.location = NULL;
310+
}
305311
}
306312
}
307313
} else {
@@ -452,11 +458,6 @@ void copy_response_headers_from_ngx(const ngx_http_request_t* r,
452458

453459
headers->set_status_code(r->headers_out.status);
454460

455-
if (r->headers_out.location != NULL) {
456-
headers->Add(HttpAttributes::kLocation,
457-
str_to_string_piece(r->headers_out.location->value));
458-
}
459-
460461
// Manually copy over the content type because it's not included in
461462
// request_->headers_out.headers.
462463
headers->Add(HttpAttributes::kContentType,

0 commit comments

Comments
 (0)