Skip to content

Commit 1a24474

Browse files
rmongiaFelipe Zimmerle
authored and
Felipe Zimmerle
committed
Passthrough the saved Response headers in the response
Tickets: #735
1 parent 254a608 commit 1a24474

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

nginx/modsecurity/ngx_http_modsecurity.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ ngx_http_modsecurity_save_headers_out_visitor(void *data,
806806
const char *key, const char *value)
807807
{
808808
ngx_http_request_t *r = data;
809-
ngx_table_elt_t *h, he;
809+
ngx_table_elt_t *h, he, *new_h;
810810
ngx_http_upstream_header_t *hh;
811811
ngx_http_upstream_main_conf_t *umcf;
812812

@@ -837,6 +837,21 @@ ngx_http_modsecurity_save_headers_out_visitor(void *data,
837837
if (hh->copy_handler(r, h, hh->conf) != NGX_OK) {
838838
return 0;
839839
}
840+
} else {
841+
/* Add the response header directly to headers_out if not present in
842+
* the hash. This is done to passthrough such response headers.
843+
* Remember the response headers were cleared earlier using
844+
* ngx_http_clean_header(r) call in ngx_http_modsecurity_save_headers_out.
845+
*/
846+
847+
new_h = ngx_list_push(&r->headers_out.headers);
848+
if (new_h == NULL) {
849+
return NGX_ERROR;
850+
}
851+
852+
new_h->hash = h->hash;
853+
new_h->key = h->key;
854+
new_h->value = h->value;
840855
}
841856

842857
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,

0 commit comments

Comments
 (0)