comparison src/http/modules/ngx_http_sub_filter_module.c @ 5229:4c1a604b0285

Sub filter: sub_filter_last_modified directive. Directive is similar to ssi_last_modified introduced by previous commit. Patch by Alexey Kolpakov.
author Maxim Dounin <mdounin@mdounin.ru>
date Fri, 24 May 2013 22:27:30 +0400
parents 4251e72b8bb4
children eaa9c732a1b9
comparison
equal deleted inserted replaced
5228:cbd4bbe976d4 5229:4c1a604b0285
15 ngx_http_complex_value_t value; 15 ngx_http_complex_value_t value;
16 16
17 ngx_hash_t types; 17 ngx_hash_t types;
18 18
19 ngx_flag_t once; 19 ngx_flag_t once;
20 ngx_flag_t last_modified;
20 21
21 ngx_array_t *types_keys; 22 ngx_array_t *types_keys;
22 } ngx_http_sub_loc_conf_t; 23 } ngx_http_sub_loc_conf_t;
23 24
24 25
85 { ngx_string("sub_filter_once"), 86 { ngx_string("sub_filter_once"),
86 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, 87 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
87 ngx_conf_set_flag_slot, 88 ngx_conf_set_flag_slot,
88 NGX_HTTP_LOC_CONF_OFFSET, 89 NGX_HTTP_LOC_CONF_OFFSET,
89 offsetof(ngx_http_sub_loc_conf_t, once), 90 offsetof(ngx_http_sub_loc_conf_t, once),
91 NULL },
92
93 { ngx_string("sub_filter_last_modified"),
94 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
95 ngx_conf_set_flag_slot,
96 NGX_HTTP_LOC_CONF_OFFSET,
97 offsetof(ngx_http_sub_loc_conf_t, last_modified),
90 NULL }, 98 NULL },
91 99
92 ngx_null_command 100 ngx_null_command
93 }; 101 };
94 102
165 173
166 r->filter_need_in_memory = 1; 174 r->filter_need_in_memory = 1;
167 175
168 if (r == r->main) { 176 if (r == r->main) {
169 ngx_http_clear_content_length(r); 177 ngx_http_clear_content_length(r);
170 ngx_http_clear_last_modified(r);
171 ngx_http_clear_etag(r); 178 ngx_http_clear_etag(r);
179
180 if (!slcf->last_modified) {
181 ngx_http_clear_last_modified(r);
182 }
172 } 183 }
173 184
174 return ngx_http_next_header_filter(r); 185 return ngx_http_next_header_filter(r);
175 } 186 }
176 187
672 * conf->types = { NULL }; 683 * conf->types = { NULL };
673 * conf->types_keys = NULL; 684 * conf->types_keys = NULL;
674 */ 685 */
675 686
676 slcf->once = NGX_CONF_UNSET; 687 slcf->once = NGX_CONF_UNSET;
688 slcf->last_modified = NGX_CONF_UNSET;
677 689
678 return slcf; 690 return slcf;
679 } 691 }
680 692
681 693
685 ngx_http_sub_loc_conf_t *prev = parent; 697 ngx_http_sub_loc_conf_t *prev = parent;
686 ngx_http_sub_loc_conf_t *conf = child; 698 ngx_http_sub_loc_conf_t *conf = child;
687 699
688 ngx_conf_merge_value(conf->once, prev->once, 1); 700 ngx_conf_merge_value(conf->once, prev->once, 1);
689 ngx_conf_merge_str_value(conf->match, prev->match, ""); 701 ngx_conf_merge_str_value(conf->match, prev->match, "");
702 ngx_conf_merge_value(conf->last_modified, prev->last_modified, 0);
690 703
691 if (conf->value.value.data == NULL) { 704 if (conf->value.value.data == NULL) {
692 conf->value = prev->value; 705 conf->value = prev->value;
693 } 706 }
694 707