comparison src/http/modules/ngx_http_range_filter_module.c @ 4055:9cce506be97d

Ranges processing small optimization.
author Igor Sysoev <igor@sysoev.ru>
date Tue, 30 Aug 2011 12:45:24 +0000
parents 20c7c73d3efa
children e9213133993a
comparison
equal deleted inserted replaced
4054:20c7c73d3efa 4055:9cce506be97d
268 } 268 }
269 269
270 while (*p == ' ') { p++; } 270 while (*p == ' ') { p++; }
271 271
272 if (*p == ',' || *p == '\0') { 272 if (*p == ',' || *p == '\0') {
273 range = ngx_array_push(&ctx->ranges); 273 end = r->headers_out.content_length_n;
274 if (range == NULL) { 274 goto found;
275 return NGX_ERROR;
276 }
277
278 range->start = start;
279 range->end = r->headers_out.content_length_n;
280 size += range->end - start;
281
282 if (*p++ != ',') {
283 break;
284 }
285
286 continue;
287 } 275 }
288 276
289 } else { 277 } else {
290 suffix = 1; 278 suffix = 1;
291 p++; 279 p++;
311 } 299 }
312 300
313 if (start > end) { 301 if (start > end) {
314 return NGX_HTTP_RANGE_NOT_SATISFIABLE; 302 return NGX_HTTP_RANGE_NOT_SATISFIABLE;
315 } 303 }
316
317 range = ngx_array_push(&ctx->ranges);
318 if (range == NULL) {
319 return NGX_ERROR;
320 }
321
322 range->start = start;
323 304
324 if (end >= r->headers_out.content_length_n) { 305 if (end >= r->headers_out.content_length_n) {
325 /* 306 /*
326 * Download Accelerator sends the last byte position 307 * Download Accelerator sends the last byte position
327 * that equals to the file length 308 * that equals to the file length
328 */ 309 */
329 range->end = r->headers_out.content_length_n; 310 end = r->headers_out.content_length_n;
330 311
331 } else { 312 } else {
332 range->end = end + 1; 313 end++;
333 } 314 }
334 315
335 size += range->end - start; 316 found:
317
318 range = ngx_array_push(&ctx->ranges);
319 if (range == NULL) {
320 return NGX_ERROR;
321 }
322
323 range->start = start;
324 range->end = end;
325
326 size += end - start;
336 327
337 if (*p++ != ',') { 328 if (*p++ != ',') {
338 break; 329 break;
339 } 330 }
340 } 331 }