@@ -205,13 +205,13 @@ ngx_http_srcache_header_filter(ngx_http_request_t *r)
205
205
return ngx_http_next_header_filter (r );
206
206
}
207
207
208
- if (slcf -> store_max_size != NGX_CONF_UNSET_SIZE
209
- && r -> headers_out .content_length_n >= (int ) slcf -> store_max_size ) {
210
- ngx_log_debug1 (NGX_LOG_DEBUG_HTTP , r -> connection -> log , 0 ,
211
- "bypass because of too large content: %d (limit is: %d)" ,
212
- r -> headers_out .content_length , slcf -> store_max_size );
213
- return ngx_http_next_header_filter (r );
214
- }
208
+ if (slcf -> store_max_size != 0
209
+ && r -> headers_out .content_length_n >= (int ) slcf -> store_max_size ) {
210
+ ngx_log_debug1 (NGX_LOG_DEBUG_HTTP , r -> connection -> log , 0 ,
211
+ "bypass because of too large content-length header : %d (limit is: %d)" ,
212
+ r -> headers_out .content_length_n , slcf -> store_max_size );
213
+ return ngx_http_next_header_filter (r );
214
+ }
215
215
216
216
dd ("try to save the response header" );
217
217
@@ -292,11 +292,12 @@ ngx_http_srcache_header_filter(ngx_http_request_t *r)
292
292
static ngx_int_t
293
293
ngx_http_srcache_body_filter (ngx_http_request_t * r , ngx_chain_t * in )
294
294
{
295
- ngx_http_request_t * pr ;
296
- ngx_http_srcache_ctx_t * ctx , * pr_ctx ;
297
- ngx_int_t rc ;
298
- ngx_chain_t * cl ;
299
- ngx_flag_t last ;
295
+ ngx_http_request_t * pr ;
296
+ ngx_http_srcache_ctx_t * ctx , * pr_ctx ;
297
+ ngx_int_t rc ;
298
+ ngx_chain_t * cl ;
299
+ ngx_flag_t last ;
300
+ ngx_http_srcache_loc_conf_t * slcf ;
300
301
301
302
302
303
dd_enter ();
@@ -381,6 +382,16 @@ ngx_http_srcache_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
381
382
}
382
383
}
383
384
385
+ slcf = ngx_http_get_module_loc_conf (r , ngx_http_srcache_filter_module );
386
+ if (slcf -> store_max_size != 0
387
+ && ctx -> body_length >= slcf -> store_max_size ) {
388
+ ngx_log_debug1 (NGX_LOG_DEBUG_HTTP , r -> connection -> log , 0 ,
389
+ "bypass because body reached maximum size: %d (limit is: %d)" ,
390
+ ctx -> body_length , slcf -> store_max_size );
391
+ ctx -> store_response = 0 ;
392
+ goto done ;
393
+ }
394
+
384
395
rc = ngx_http_srcache_add_copy_chain (r -> pool , & ctx -> body_to_cache , in );
385
396
386
397
if (rc != NGX_OK ) {
@@ -473,7 +484,7 @@ ngx_http_srcache_create_loc_conf(ngx_conf_t *cf)
473
484
474
485
slcf -> buf_size = NGX_CONF_UNSET_SIZE ;
475
486
476
- slcf -> store_max_size = NGX_CONF_UNSET_SIZE ;
487
+ slcf -> store_max_size = NGX_CONF_UNSET_SIZE ;
477
488
478
489
return slcf ;
479
490
}
@@ -492,7 +503,7 @@ ngx_http_srcache_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
492
503
(size_t ) ngx_pagesize );
493
504
494
505
ngx_conf_merge_size_value (conf -> store_max_size , prev -> store_max_size ,
495
- NGX_CONF_UNSET_SIZE );
506
+ 0 );
496
507
497
508
return NGX_CONF_OK ;
498
509
}
0 commit comments