18
18
19
19
static ngx_int_t ngx_http_srcache_fetch_subrequest (ngx_http_request_t * r ,
20
20
ngx_http_srcache_loc_conf_t * conf , ngx_http_srcache_ctx_t * ctx );
21
- static ngx_int_t ngx_http_srcache_fetch_header_filter (ngx_http_request_t * r );
22
- static ngx_int_t ngx_http_srcache_test_not_modified (ngx_http_request_t * r );
23
- #if defined(nginx_version ) && (nginx_version >= 9002 )
24
- static ngx_int_t ngx_http_srcache_test_precondition (ngx_http_request_t * r );
25
- #endif
26
21
static void ngx_http_srcache_post_read_body (ngx_http_request_t * r );
27
22
28
23
@@ -160,7 +155,7 @@ ngx_http_srcache_access_handler(ngx_http_request_t *r)
160
155
161
156
r -> headers_out .content_length_n = len ;
162
157
163
- rc = ngx_http_srcache_fetch_header_filter (r );
158
+ rc = ngx_http_send_header (r );
164
159
165
160
dd ("srcache fetch header returned %d" , (int ) rc );
166
161
@@ -175,15 +170,8 @@ ngx_http_srcache_access_handler(ngx_http_request_t *r)
175
170
#endif
176
171
177
172
if (!r -> filter_finalize ) {
178
- rc = ngx_http_srcache_next_body_filter (r ,
179
- ctx -> body_from_cache );
180
-
181
- if (rc == NGX_ERROR ) {
182
- r -> connection -> error = 1 ;
183
- return NGX_ERROR ;
184
- }
185
-
186
- if (rc > NGX_OK ) {
173
+ rc = ngx_http_output_filter (r , ctx -> body_from_cache );
174
+ if (rc == NGX_ERROR || rc > NGX_OK ) {
187
175
return rc ;
188
176
}
189
177
}
@@ -446,95 +434,6 @@ ngx_http_srcache_fetch_subrequest(ngx_http_request_t *r,
446
434
}
447
435
448
436
449
- static ngx_int_t
450
- ngx_http_srcache_fetch_header_filter (ngx_http_request_t * r )
451
- {
452
- if (r -> headers_out .status != NGX_HTTP_OK
453
- || r -> headers_out .last_modified_time == -1 )
454
- {
455
- return ngx_http_srcache_next_header_filter (r );
456
- }
457
-
458
- #if defined(nginx_version ) && (nginx_version >= 9002 )
459
- if (r -> headers_in .if_unmodified_since ) {
460
- return ngx_http_srcache_test_precondition (r );
461
- }
462
- #endif
463
-
464
- if (r -> headers_in .if_modified_since ) {
465
- return ngx_http_srcache_test_not_modified (r );
466
- }
467
-
468
- return ngx_http_srcache_next_header_filter (r );
469
- }
470
-
471
-
472
- static ngx_int_t
473
- ngx_http_srcache_test_not_modified (ngx_http_request_t * r )
474
- {
475
- time_t ims ;
476
- ngx_http_core_loc_conf_t * clcf ;
477
-
478
- clcf = ngx_http_get_module_loc_conf (r , ngx_http_core_module );
479
-
480
- if (clcf -> if_modified_since == NGX_HTTP_IMS_OFF ) {
481
- return ngx_http_srcache_next_header_filter (r );
482
- }
483
-
484
- ims = ngx_http_parse_time (r -> headers_in .if_modified_since -> value .data ,
485
- r -> headers_in .if_modified_since -> value .len );
486
-
487
- ngx_log_debug2 (NGX_LOG_DEBUG_HTTP , r -> connection -> log , 0 ,
488
- "srcache ims:%d lm:%d" , ims ,
489
- r -> headers_out .last_modified_time );
490
-
491
- if (ims != r -> headers_out .last_modified_time ) {
492
-
493
- if (clcf -> if_modified_since == NGX_HTTP_IMS_EXACT
494
- || ims < r -> headers_out .last_modified_time )
495
- {
496
- return ngx_http_srcache_next_header_filter (r );
497
- }
498
- }
499
-
500
- r -> headers_out .status = NGX_HTTP_NOT_MODIFIED ;
501
- r -> headers_out .status_line .len = 0 ;
502
- r -> headers_out .content_type .len = 0 ;
503
- ngx_http_clear_content_length (r );
504
- ngx_http_clear_accept_ranges (r );
505
-
506
- if (r -> headers_out .content_encoding ) {
507
- r -> headers_out .content_encoding -> hash = 0 ;
508
- r -> headers_out .content_encoding = NULL ;
509
- }
510
-
511
- return ngx_http_srcache_next_header_filter (r );
512
- }
513
-
514
-
515
- #if defined(nginx_version ) && (nginx_version >= 9002 )
516
- static ngx_int_t
517
- ngx_http_srcache_test_precondition (ngx_http_request_t * r )
518
- {
519
- time_t iums ;
520
-
521
- iums = ngx_http_parse_time (r -> headers_in .if_unmodified_since -> value .data ,
522
- r -> headers_in .if_unmodified_since -> value .len );
523
-
524
- ngx_log_debug2 (NGX_LOG_DEBUG_HTTP , r -> connection -> log , 0 ,
525
- "srcache iums:%d lm:%d" , iums ,
526
- r -> headers_out .last_modified_time );
527
-
528
- if (iums >= r -> headers_out .last_modified_time ) {
529
- return ngx_http_srcache_next_header_filter (r );
530
- }
531
-
532
- return ngx_http_filter_finalize_request (r , NULL ,
533
- NGX_HTTP_PRECONDITION_FAILED );
534
- }
535
- #endif
536
-
537
-
538
437
static void
539
438
ngx_http_srcache_post_read_body (ngx_http_request_t * r )
540
439
{
0 commit comments