Mercurial > hg > nginx
comparison src/http/modules/ngx_http_range_filter.c @ 165:894a01c6aea3
nginx-0.0.1-2003-10-29-20:39:05 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 29 Oct 2003 17:39:05 +0000 |
parents | 84036764e215 |
children | 4db54fdbcbe7 |
comparison
equal
deleted
inserted
replaced
164:84036764e215 | 165:894a01c6aea3 |
---|---|
196 /* rc == NGX_HTTP_RANGE_NOT_SATISFIABLE */ | 196 /* rc == NGX_HTTP_RANGE_NOT_SATISFIABLE */ |
197 | 197 |
198 r->headers_out.status = rc; | 198 r->headers_out.status = rc; |
199 r->headers_out.ranges.nelts = 0; | 199 r->headers_out.ranges.nelts = 0; |
200 | 200 |
201 ngx_test_null(r->headers_out.content_range, | 201 if (!(r->headers_out.content_range = |
202 ngx_push_table(r->headers_out.headers), | 202 ngx_http_add_header(&r->headers_out, ngx_http_headers_out))) |
203 NGX_ERROR); | 203 { |
204 return NGX_ERROR; | |
205 } | |
206 | |
207 r->headers_out.content_range->key.len = sizeof("Content-Range") - 1; | |
208 r->headers_out.content_range->key.data = "Content-Range"; | |
204 | 209 |
205 ngx_test_null(r->headers_out.content_range->value.data, | 210 ngx_test_null(r->headers_out.content_range->value.data, |
206 ngx_palloc(r->pool, 8 + 20 + 1), | 211 ngx_palloc(r->pool, 8 + 20 + 1), |
207 NGX_ERROR); | 212 NGX_ERROR); |
208 | 213 |
210 ngx_snprintf(r->headers_out.content_range->value.data, | 215 ngx_snprintf(r->headers_out.content_range->value.data, |
211 8 + 20 + 1, "bytes */" OFF_FMT, | 216 8 + 20 + 1, "bytes */" OFF_FMT, |
212 r->headers_out.content_length_n); | 217 r->headers_out.content_length_n); |
213 | 218 |
214 r->headers_out.content_length_n = -1; | 219 r->headers_out.content_length_n = -1; |
215 r->headers_out.content_length = NULL; | 220 if (r->headers_out.content_length) { |
221 r->headers_out.content_length->key.len = 0; | |
222 r->headers_out.content_length = NULL; | |
223 } | |
216 | 224 |
217 return rc; | 225 return rc; |
218 | 226 |
219 } else { | 227 } else { |
220 r->headers_out.status = NGX_HTTP_PARTIAL_CONTENT; | 228 r->headers_out.status = NGX_HTTP_PARTIAL_CONTENT; |
221 | 229 |
222 if (r->headers_out.ranges.nelts == 1) { | 230 if (r->headers_out.ranges.nelts == 1) { |
223 ngx_test_null(r->headers_out.content_range, | 231 |
224 ngx_push_table(r->headers_out.headers), | 232 if (!(r->headers_out.content_range = |
225 NGX_ERROR); | 233 ngx_http_add_header(&r->headers_out, ngx_http_headers_out))) |
234 { | |
235 return NGX_ERROR; | |
236 } | |
237 | |
238 r->headers_out.content_range->key.len = sizeof("Content-Range") - 1; | |
239 r->headers_out.content_range->key.data = "Content-Range"; | |
226 | 240 |
227 ngx_test_null(r->headers_out.content_range->value.data, | 241 ngx_test_null(r->headers_out.content_range->value.data, |
228 ngx_palloc(r->pool, 6 + 20 + 1 + 20 + 1 + 20 + 1), | 242 ngx_palloc(r->pool, 6 + 20 + 1 + 20 + 1 + 20 + 1), |
229 NGX_ERROR); | 243 NGX_ERROR); |
230 | 244 |
241 | 255 |
242 } else { | 256 } else { |
243 | 257 |
244 #if 0 | 258 #if 0 |
245 /* TODO: what if no content_type ?? */ | 259 /* TODO: what if no content_type ?? */ |
246 ngx_test_null(r->headers_out.content_type, | 260 |
247 ngx_push_table(r->headers_out.headers), | 261 if (!(r->headers_out.content_type = |
248 NGX_ERROR); | 262 ngx_http_add_header(&r->headers_out, ngx_http_headers_out))) |
263 { | |
264 return NGX_ERROR; | |
265 } | |
249 #endif | 266 #endif |
250 | 267 |
251 ngx_http_create_ctx(r, ctx, ngx_http_range_filter_module, | 268 ngx_http_create_ctx(r, ctx, ngx_http_range_filter_module, |
252 sizeof(ngx_http_range_filter_ctx_t), NGX_ERROR); | 269 sizeof(ngx_http_range_filter_ctx_t), NGX_ERROR); |
253 | 270 |