Mercurial > hg > nginx-vendor-current
comparison src/http/ngx_http_header_filter_module.c @ 454:a8424ffa495c NGINX_0_7_39
nginx 0.7.39
*) Bugfix: large response with SSI might hang, if gzipping was enabled;
the bug had appeared in 0.7.28.
Thanks to Artem Bokhan.
*) Bugfix: a segmentation fault might occur in worker process, if short
static variants are used in a "try_files" directive.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 02 Mar 2009 00:00:00 +0300 |
parents | 76a79816b771 |
children | ca8f7f6cab16 |
comparison
equal
deleted
inserted
replaced
453:9ef0e36f3cd5 | 454:a8424ffa495c |
---|---|
153 { | 153 { |
154 u_char *p; | 154 u_char *p; |
155 size_t len; | 155 size_t len; |
156 ngx_str_t host; | 156 ngx_str_t host; |
157 ngx_buf_t *b; | 157 ngx_buf_t *b; |
158 ngx_uint_t status, i; | 158 ngx_uint_t status, i, port; |
159 ngx_chain_t out; | 159 ngx_chain_t out; |
160 ngx_list_part_t *part; | 160 ngx_list_part_t *part; |
161 ngx_table_elt_t *header; | 161 ngx_table_elt_t *header; |
162 ngx_http_core_loc_conf_t *clcf; | 162 ngx_http_core_loc_conf_t *clcf; |
163 ngx_http_core_srv_conf_t *cscf; | 163 ngx_http_core_srv_conf_t *cscf; |
164 struct sockaddr_in *sin; | |
165 #if (NGX_HAVE_INET6) | |
166 struct sockaddr_in6 *sin6; | |
167 #endif | |
164 u_char addr[NGX_SOCKADDR_STRLEN]; | 168 u_char addr[NGX_SOCKADDR_STRLEN]; |
165 | 169 |
166 r->header_sent = 1; | 170 r->header_sent = 1; |
167 | 171 |
168 if (r != r->main) { | 172 if (r != r->main) { |
295 if (ngx_http_server_addr(r, &host) != NGX_OK) { | 299 if (ngx_http_server_addr(r, &host) != NGX_OK) { |
296 return NGX_ERROR; | 300 return NGX_ERROR; |
297 } | 301 } |
298 } | 302 } |
299 | 303 |
304 switch (r->connection->local_sockaddr->sa_family) { | |
305 | |
306 #if (NGX_HAVE_INET6) | |
307 case AF_INET6: | |
308 sin6 = (struct sockaddr_in6 *) r->connection->local_sockaddr; | |
309 port = ntohs(sin6->sin6_port); | |
310 break; | |
311 #endif | |
312 default: /* AF_INET */ | |
313 sin = (struct sockaddr_in *) r->connection->local_sockaddr; | |
314 port = ntohs(sin->sin_port); | |
315 break; | |
316 } | |
317 | |
318 len += sizeof("Location: https://") - 1 | |
319 + host.len | |
320 + r->headers_out.location->value.len + 2; | |
321 | |
322 if (clcf->port_in_redirect) { | |
323 | |
300 #if (NGX_HTTP_SSL) | 324 #if (NGX_HTTP_SSL) |
301 if (r->connection->ssl) { | 325 if (r->connection->ssl) |
302 len += sizeof("Location: https://") - 1 | 326 port = (port == 443) ? 0 : port; |
303 + host.len | 327 else |
304 + r->headers_out.location->value.len + 2; | 328 #endif |
305 | 329 port = (port == 80) ? 0 : port; |
306 if (clcf->port_in_redirect && r->port != 443) { | 330 } |
307 len += r->port_text->len; | 331 |
308 } | 332 if (port) { |
309 | 333 len += sizeof(":65535") - 1; |
310 } else | |
311 #endif | |
312 { | |
313 len += sizeof("Location: http://") - 1 | |
314 + host.len | |
315 + r->headers_out.location->value.len + 2; | |
316 | |
317 if (clcf->port_in_redirect && r->port != 80) { | |
318 len += r->port_text->len; | |
319 } | |
320 } | 334 } |
321 | 335 |
322 } else { | 336 } else { |
323 host.len = 0; | 337 host.len = 0; |
324 host.data = NULL; | 338 host.data = NULL; |
339 port = 0; | |
325 } | 340 } |
326 | 341 |
327 if (r->chunked) { | 342 if (r->chunked) { |
328 len += sizeof("Transfer-Encoding: chunked" CRLF) - 1; | 343 len += sizeof("Transfer-Encoding: chunked" CRLF) - 1; |
329 } | 344 } |
471 #endif | 486 #endif |
472 | 487 |
473 *b->last++ = ':'; *b->last++ = '/'; *b->last++ = '/'; | 488 *b->last++ = ':'; *b->last++ = '/'; *b->last++ = '/'; |
474 b->last = ngx_copy(b->last, host.data, host.len); | 489 b->last = ngx_copy(b->last, host.data, host.len); |
475 | 490 |
476 if (clcf->port_in_redirect) { | 491 if (port) { |
477 #if (NGX_HTTP_SSL) | 492 b->last = ngx_sprintf(b->last, ":%ui", port); |
478 if (r->connection->ssl) { | |
479 if (r->port != 443) { | |
480 b->last = ngx_copy(b->last, r->port_text->data, | |
481 r->port_text->len); | |
482 } | |
483 } else | |
484 #endif | |
485 { | |
486 if (r->port != 80) { | |
487 b->last = ngx_copy(b->last, r->port_text->data, | |
488 r->port_text->len); | |
489 } | |
490 } | |
491 } | 493 } |
492 | 494 |
493 b->last = ngx_copy(b->last, r->headers_out.location->value.data, | 495 b->last = ngx_copy(b->last, r->headers_out.location->value.data, |
494 r->headers_out.location->value.len); | 496 r->headers_out.location->value.len); |
495 | 497 |