Skip to content

Match API for response status/proto handling #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/ngx_http_modsecurity_header_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ ngx_int_t ngx_http_modsecurity_header_filter(ngx_http_request_t *r)
ngx_table_elt_t *data = part->elts;
ngx_uint_t i = 0;
int ret = 0;
ngx_uint_t status;
const char *response_proto;

ctx = ngx_http_get_module_ctx(r, ngx_http_modsecurity);

Expand Down Expand Up @@ -92,7 +94,20 @@ ngx_int_t ngx_http_modsecurity_header_filter(ngx_http_request_t *r)
data[i].value.len);
}

msc_process_response_headers(ctx->modsec_transaction);
if (r->err_status) {
status = r->err_status;
} else {
status = r->headers_out.status;
}

response_proto = "HTTP 1.1";
#if (NGX_HTTP_V2)
if (r->stream) {
response_proto = "HTTP 2.0";
}
#endif

msc_process_response_headers(ctx->modsec_transaction, status, response_proto);
ret = ngx_http_modsecurity_process_intervention(ctx->modsec_transaction, r);
if (ret > 0)
{
Expand Down
3 changes: 1 addition & 2 deletions src/ngx_http_modsecurity_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ ngx_int_t ngx_http_modsecurity_log_handler(ngx_http_request_t *r)
{
ngx_http_modsecurity_ctx_t *ctx = NULL;
ngx_http_modsecurity_loc_conf_t *cf;
ngx_uint_t status = r->headers_out.status;

dd("catching a new _log_ pahase handler");

Expand Down Expand Up @@ -67,7 +66,7 @@ ngx_int_t ngx_http_modsecurity_log_handler(ngx_http_request_t *r)
}

dd("calling msc_process_logging for %p", ctx);
msc_process_logging(ctx->modsec_transaction, status);
msc_process_logging(ctx->modsec_transaction);

return NGX_OK;
}