Mercurial > hg > nginx
comparison src/http/modules/ngx_http_range_filter_module.c @ 4745:4752060ca462
Entity tags: support in If-Range header.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Sat, 07 Jul 2012 21:21:15 +0000 |
parents | 5ea8c710c532 |
children | 149634c98d67 |
comparison
equal
deleted
inserted
replaced
4744:5b93a9ac60ed | 4745:4752060ca462 |
---|---|
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 |
174 goto next_filter; | 175 goto next_filter; |
175 } | 176 } |
176 | 177 |
177 if (r->headers_in.if_range) { | 178 if (r->headers_in.if_range) { |
178 | 179 |
180 if_range = &r->headers_in.if_range->value; | |
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 | |
179 if (r->headers_out.last_modified_time == (time_t) -1) { | 202 if (r->headers_out.last_modified_time == (time_t) -1) { |
180 goto next_filter; | 203 goto next_filter; |
181 } | 204 } |
182 | 205 |
183 if_range = ngx_http_parse_time(r->headers_in.if_range->value.data, | 206 if_range_time = ngx_http_parse_time(if_range->data, if_range->len); |
184 r->headers_in.if_range->value.len); | |
185 | 207 |
186 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 208 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
187 "http ir:%d lm:%d", | 209 "http ir:%d lm:%d", |
188 if_range, r->headers_out.last_modified_time); | 210 if_range_time, r->headers_out.last_modified_time); |
189 | 211 |
190 if (if_range != r->headers_out.last_modified_time) { | 212 if (if_range_time != r->headers_out.last_modified_time) { |
191 goto next_filter; | 213 goto next_filter; |
192 } | 214 } |
193 } | 215 } |
216 | |
217 parse: | |
194 | 218 |
195 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)); |
196 if (ctx == NULL) { | 220 if (ctx == NULL) { |
197 return NGX_ERROR; | 221 return NGX_ERROR; |
198 } | 222 } |