Skip to content

Commit 251e9a7

Browse files
committed
modsecurity: fix reponse status & http version
1 parent 8484662 commit 251e9a7

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

src/ngx_http_modsecurity_header_filter.c

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ static ngx_int_t
3939
ngx_http_modsecurity_header_filter(ngx_http_request_t *r)
4040
{
4141
int rc;
42-
char *http_response_ver;
43-
ngx_uint_t i, status;
42+
char *http_protocol;
43+
ngx_uint_t i;
4444
ngx_pool_t *old_pool;
4545
ngx_list_part_t *part;
4646
ngx_table_elt_t *header;
@@ -82,26 +82,17 @@ ngx_http_modsecurity_header_filter(ngx_http_request_t *r)
8282
header[i].value.data, header[i].value.len);
8383
}
8484

85-
/* prepare extra paramters for msc_process_response_headers() */
86-
if (r->err_status) {
87-
status = r->err_status;
85+
if (r->http_version < NGX_HTTP_VERSION_10) {
86+
http_protocol = "HTTP/0.9";
87+
} else if (r->http_version < NGX_HTTP_VERSION_20) {
88+
http_protocol = "HTTP/1.1";
8889
} else {
89-
status = r->headers_out.status;
90+
http_protocol = (char *)r->http_protocol.data;
9091
}
9192

92-
/*
93-
* NGINX always sends HTTP response with HTTP/1.1, except cases when
94-
* HTTP V2 module is enabled, and request has been posted with HTTP/2.0.
95-
*/
96-
http_response_ver = "HTTP 1.1";
97-
#if (NGX_HTTP_V2)
98-
if (r->stream) {
99-
http_response_ver = "HTTP 2.0";
100-
}
101-
#endif
102-
10393
old_pool = ngx_http_modsecurity_pcre_malloc_init(r->pool);
104-
msc_process_response_headers(ctx->modsec_transaction, status, http_response_ver);
94+
msc_process_response_headers(ctx->modsec_transaction, r->headers_out.status,
95+
http_protocol);
10596
ngx_http_modsecurity_pcre_malloc_done(old_pool);
10697
rc = ngx_http_modsecurity_process_intervention(ctx->modsec_transaction, r, 0);
10798
if (r->error_page) {

0 commit comments

Comments
 (0)