Skip to content
Browse files

Passthrough the saved Response headers in the response

Tickets: #735
  • Loading branch information...
1 parent 20ecdcc commit 04d0426767f92d423f4fa4f56eada4e09814b02d @rmongia rmongia committed with zimmerle Jun 30, 2014
Showing with 16 additions and 2 deletions.
  1. +16 −2 nginx/modsecurity/ngx_http_modsecurity.c
View
18 nginx/modsecurity/ngx_http_modsecurity.c
@@ -806,7 +806,7 @@ ngx_http_modsecurity_save_headers_out_visitor(void *data,
const char *key, const char *value)
{
ngx_http_request_t *r = data;
- ngx_table_elt_t *h, he;
+ ngx_table_elt_t *h, he, *new_h;
ngx_http_upstream_header_t *hh;
ngx_http_upstream_main_conf_t *umcf;
@@ -837,6 +837,21 @@ ngx_http_modsecurity_save_headers_out_visitor(void *data,
if (hh->copy_handler(r, h, hh->conf) != NGX_OK) {
return 0;
}
+ } else {
+ /* Add the response header directly to headers_out if not present in
+ * the hash. This is done to passthrough such response headers.
+ * Remember the response headers were cleared earlier using
+ * ngx_http_clean_header(r) call in ngx_http_modsecurity_save_headers_out.
+ */
+
+ new_h = ngx_list_push(&r->headers_out.headers);
+ if (new_h == NULL) {
+ return NGX_ERROR;
+ }
+
+ new_h->hash = h->hash;
+ new_h->key = h->key;
+ new_h->value = h->value;
}
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
@@ -1388,7 +1403,6 @@ ngx_http_modsecurity_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"ModSecurity: save headers out done _inside_");
-
return ngx_http_filter_finalize_request(r,
&ngx_http_modsecurity, NGX_HTTP_INTERNAL_SERVER_ERROR);
}

0 comments on commit 04d0426

Please sign in to comment.
Something went wrong with that request. Please try again.