Skip to content

Commit fd2c30f

Browse files
committed
Nginx: minor improve
1 parent 9b13d24 commit fd2c30f

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

nginx/modsecurity/ngx_http_modsecurity.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,7 @@ ngx_http_modsecurity_header_filter(ngx_http_request_t *r) {
11081108
return ngx_http_next_header_filter(r);
11091109
}
11101110

1111-
if (r != r->main || !cf->enable || ctx->complete) {
1111+
if (r != r->main || !cf->enable || ctx == NULL ||ctx->complete) {
11121112
return ngx_http_next_header_filter(r);
11131113
}
11141114

@@ -1140,6 +1140,10 @@ ngx_http_modsecurity_header_filter(ngx_http_request_t *r) {
11401140
}
11411141

11421142
/* SecResponseBodyAccess on, process rules in body filter */
1143+
1144+
/* pretend we are ngx_http_header_filter */
1145+
r->header_sent = 1;
1146+
11431147
r->filter_need_in_memory = 1;
11441148
return NGX_OK;
11451149
}
@@ -1156,7 +1160,7 @@ ngx_http_modsecurity_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
11561160
cf = ngx_http_get_module_loc_conf(r, ngx_http_modsecurity);
11571161
ctx = ngx_http_get_module_ctx(r, ngx_http_modsecurity);
11581162

1159-
if (r != r->main || !cf->enable || ctx->complete) {
1163+
if (r != r->main || !cf->enable || ctx == NULL || ctx->complete) {
11601164
return ngx_http_next_body_filter(r, in);
11611165
}
11621166

@@ -1212,6 +1216,7 @@ ngx_http_modsecurity_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
12121216
r->headers_out.content_length = NULL; /* header filter will set this */
12131217
}
12141218

1219+
r->header_sent = 0;
12151220
rc = ngx_http_next_header_filter(r);
12161221

12171222
if (rc == NGX_ERROR || rc > NGX_OK) {

nginx/modsecurity/ngx_pool_context.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ ngx_pool_context_init_conf(ngx_cycle_t *cycle, void *conf)
196196
{
197197
ngx_pool_context_conf_t *pcf = conf;
198198

199-
ngx_conf_init_uint_value(pcf->size, NGX_POOL_CTX_SIZE);
199+
ngx_conf_init_uint_value(pcf->size, cycle->connection_n);
200200

201201
ngx_pool_context_hash_size = pcf->size;
202202

0 commit comments

Comments
 (0)