Fixed: Nginx return 500 when request body is off

This commit is contained in:
Breno Silva 2013-03-05 02:38:46 -04:00
parent df383b9b80
commit 43162f52cf

View File

@ -387,9 +387,11 @@ ngx_http_modsecurity_handler(ngx_http_request_t *r)
return NGX_DONE; return NGX_DONE;
} }
/* other method */ /* other method */
if(modsecIsRequestBodyAccessEnabled(ctx->req)) {
rc = modsecProcessRequestBody(ctx->req); rc = modsecProcessRequestBody(ctx->req);
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "ModSecurity: modsecProcessRequestBody %d", rc); ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "ModSecurity: modsecProcessRequestBody %d", rc);
} }
}
if (rc != DECLINED) { if (rc != DECLINED) {
@ -430,13 +432,15 @@ ngx_http_modsecurity_body_handler(ngx_http_request_t *r)
return ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); return ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
} }
rc = DECLINED;
r->request_body = NULL; r->request_body = NULL;
modsecSetBodyBrigade(ctx->req, ctx->brigade); modsecSetBodyBrigade(ctx->req, ctx->brigade);
if(modsecIsRequestBodyAccessEnabled(ctx->req)) if(modsecIsRequestBodyAccessEnabled(ctx->req)) {
rc = modsecProcessRequestBody(ctx->req); rc = modsecProcessRequestBody(ctx->req);
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "ModSecurity: modsecProcessRequestBody %d", rc); ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "ModSecurity: modsecProcessRequestBody %d", rc);
}
if (rc != DECLINED) { if (rc != DECLINED) {
/* Nginx and Apache share same response code */ /* Nginx and Apache share same response code */