comparison src/http/modules/ngx_http_range_filter_module.c @ 680:597573166f34 NGINX_1_3_3

nginx 1.3.3 *) Feature: entity tags support and the "etag" directive. *) Bugfix: trailing dot in a source value was not ignored if the "map" directive was used with the "hostnames" parameter. *) Bugfix: incorrect location might be used to process a request if a URI was changed via a "rewrite" directive before an internal redirect to a named location.
author Igor Sysoev <http://sysoev.ru>
date Tue, 10 Jul 2012 00:00:00 +0400
parents e5fa0a4a7d27
children
comparison
equal deleted inserted replaced
679:cad34cec7d3b 680:597573166f34
144 144
145 145
146 static ngx_int_t 146 static ngx_int_t
147 ngx_http_range_header_filter(ngx_http_request_t *r) 147 ngx_http_range_header_filter(ngx_http_request_t *r)
148 { 148 {
149 time_t if_range; 149 time_t if_range_time;
150 ngx_str_t *if_range, *etag;
150 ngx_http_core_loc_conf_t *clcf; 151 ngx_http_core_loc_conf_t *clcf;
151 ngx_http_range_filter_ctx_t *ctx; 152 ngx_http_range_filter_ctx_t *ctx;
152 153
153 if (r->http_version < NGX_HTTP_VERSION_10 154 if (r->http_version < NGX_HTTP_VERSION_10
154 || r->headers_out.status != NGX_HTTP_OK 155 || r->headers_out.status != NGX_HTTP_OK
172 != 0) 173 != 0)
173 { 174 {
174 goto next_filter; 175 goto next_filter;
175 } 176 }
176 177
177 if (r->headers_in.if_range && r->headers_out.last_modified_time != -1) { 178 if (r->headers_in.if_range) {
178 179
179 if_range = ngx_http_parse_time(r->headers_in.if_range->value.data, 180 if_range = &r->headers_in.if_range->value;
180 r->headers_in.if_range->value.len); 181
182 if (if_range->len >= 2 && if_range->data[if_range->len - 1] == '"') {
183
184 if (r->headers_out.etag == NULL) {
185 goto next_filter;
186 }
187
188 etag = &r->headers_out.etag->value;
189
190 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
191 "http ir:%V etag:%V", if_range, etag);
192
193 if (if_range->len != etag->len
194 || ngx_strncmp(if_range->data, etag->data, etag->len) != 0)
195 {
196 goto next_filter;
197 }
198
199 goto parse;
200 }
201
202 if (r->headers_out.last_modified_time == (time_t) -1) {
203 goto next_filter;
204 }
205
206 if_range_time = ngx_http_parse_time(if_range->data, if_range->len);
181 207
182 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 208 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
183 "http ir:%d lm:%d", 209 "http ir:%d lm:%d",
184 if_range, r->headers_out.last_modified_time); 210 if_range_time, r->headers_out.last_modified_time);
185 211
186 if (if_range != r->headers_out.last_modified_time) { 212 if (if_range_time != r->headers_out.last_modified_time) {
187 goto next_filter; 213 goto next_filter;
188 } 214 }
189 } 215 }
216
217 parse:
190 218
191 ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_range_filter_ctx_t)); 219 ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_range_filter_ctx_t));
192 if (ctx == NULL) { 220 if (ctx == NULL) {
193 return NGX_ERROR; 221 return NGX_ERROR;
194 } 222 }