Mercurial > hg > nginx
comparison src/http/modules/ngx_http_range_filter_module.c @ 5558:eeb3c2719147
Range filter: fixed duplicate charset.
If a proxied response had charset in Content-Type, the
charset was duplicated in a response to client request
with byte ranges.
author | Ruslan Ermilov <ru@nginx.com> |
---|---|
date | Tue, 04 Feb 2014 17:13:35 +0400 |
parents | a387ce36744a |
children | 345e4fd4bb64 |
comparison
equal
deleted
inserted
replaced
5557:188481078faf | 5558:eeb3c2719147 |
---|---|
430 len = sizeof(CRLF "--") - 1 + NGX_ATOMIC_T_LEN | 430 len = sizeof(CRLF "--") - 1 + NGX_ATOMIC_T_LEN |
431 + sizeof(CRLF "Content-Type: ") - 1 | 431 + sizeof(CRLF "Content-Type: ") - 1 |
432 + r->headers_out.content_type.len | 432 + r->headers_out.content_type.len |
433 + sizeof(CRLF "Content-Range: bytes ") - 1; | 433 + sizeof(CRLF "Content-Range: bytes ") - 1; |
434 | 434 |
435 if (r->headers_out.charset.len) { | 435 if (r->headers_out.content_type_len == r->headers_out.content_type.len |
436 && r->headers_out.charset.len) | |
437 { | |
436 len += sizeof("; charset=") - 1 + r->headers_out.charset.len; | 438 len += sizeof("; charset=") - 1 + r->headers_out.charset.len; |
437 } | 439 } |
438 | 440 |
439 ctx->boundary_header.data = ngx_pnalloc(r->pool, len); | 441 ctx->boundary_header.data = ngx_pnalloc(r->pool, len); |
440 if (ctx->boundary_header.data == NULL) { | 442 if (ctx->boundary_header.data == NULL) { |
449 * "--0123456789" CRLF | 451 * "--0123456789" CRLF |
450 * "Content-Type: image/jpeg" CRLF | 452 * "Content-Type: image/jpeg" CRLF |
451 * "Content-Range: bytes " | 453 * "Content-Range: bytes " |
452 */ | 454 */ |
453 | 455 |
454 if (r->headers_out.charset.len) { | 456 if (r->headers_out.content_type_len == r->headers_out.content_type.len |
457 && r->headers_out.charset.len) | |
458 { | |
455 ctx->boundary_header.len = ngx_sprintf(ctx->boundary_header.data, | 459 ctx->boundary_header.len = ngx_sprintf(ctx->boundary_header.data, |
456 CRLF "--%0muA" CRLF | 460 CRLF "--%0muA" CRLF |
457 "Content-Type: %V; charset=%V" CRLF | 461 "Content-Type: %V; charset=%V" CRLF |
458 "Content-Range: bytes ", | 462 "Content-Range: bytes ", |
459 boundary, | 463 boundary, |
460 &r->headers_out.content_type, | 464 &r->headers_out.content_type, |
461 &r->headers_out.charset) | 465 &r->headers_out.charset) |
462 - ctx->boundary_header.data; | 466 - ctx->boundary_header.data; |
463 | 467 |
464 r->headers_out.charset.len = 0; | |
465 | |
466 } else if (r->headers_out.content_type.len) { | 468 } else if (r->headers_out.content_type.len) { |
467 ctx->boundary_header.len = ngx_sprintf(ctx->boundary_header.data, | 469 ctx->boundary_header.len = ngx_sprintf(ctx->boundary_header.data, |
468 CRLF "--%0muA" CRLF | 470 CRLF "--%0muA" CRLF |
469 "Content-Type: %V" CRLF | 471 "Content-Type: %V" CRLF |
470 "Content-Range: bytes ", | 472 "Content-Range: bytes ", |
499 boundary) | 501 boundary) |
500 - r->headers_out.content_type.data; | 502 - r->headers_out.content_type.data; |
501 | 503 |
502 r->headers_out.content_type_len = r->headers_out.content_type.len; | 504 r->headers_out.content_type_len = r->headers_out.content_type.len; |
503 | 505 |
506 r->headers_out.charset.len = 0; | |
507 | |
504 /* the size of the last boundary CRLF "--0123456789--" CRLF */ | 508 /* the size of the last boundary CRLF "--0123456789--" CRLF */ |
505 | 509 |
506 len = sizeof(CRLF "--") - 1 + NGX_ATOMIC_T_LEN + sizeof("--" CRLF) - 1; | 510 len = sizeof(CRLF "--") - 1 + NGX_ATOMIC_T_LEN + sizeof("--" CRLF) - 1; |
507 | 511 |
508 range = ctx->ranges.elts; | 512 range = ctx->ranges.elts; |