comparison src/http/ngx_http_header_filter_module.c @ 2533:c843171d5dc2

axe r->port_text
author Igor Sysoev <igor@sysoev.ru>
date Tue, 24 Feb 2009 07:29:55 +0000
parents aa53ef3e36e9
children 0e6f00346fa1
comparison
equal deleted inserted replaced
2532:aa53ef3e36e9 2533:c843171d5dc2
313 sin = (struct sockaddr_in *) r->connection->local_sockaddr; 313 sin = (struct sockaddr_in *) r->connection->local_sockaddr;
314 port = ntohs(sin->sin_port); 314 port = ntohs(sin->sin_port);
315 break; 315 break;
316 } 316 }
317 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
318 #if (NGX_HTTP_SSL) 324 #if (NGX_HTTP_SSL)
319 if (r->connection->ssl) { 325 if (r->connection->ssl)
320 len += sizeof("Location: https://") - 1 326 port = (port == 443) ? 0 : port;
321 + host.len 327 else
322 + r->headers_out.location->value.len + 2; 328 #endif
323 329 port = (port == 80) ? 0 : port;
324 if (clcf->port_in_redirect && port != 443) { 330 }
325 len += r->port_text->len; 331
326 } 332 if (port) {
327 333 len += sizeof(":65535") - 1;
328 } else
329 #endif
330 {
331 len += sizeof("Location: http://") - 1
332 + host.len
333 + r->headers_out.location->value.len + 2;
334
335 if (clcf->port_in_redirect && port != 80) {
336 len += r->port_text->len;
337 }
338 } 334 }
339 335
340 } else { 336 } else {
341 host.len = 0; 337 host.len = 0;
342 host.data = NULL; 338 host.data = NULL;
490 #endif 486 #endif
491 487
492 *b->last++ = ':'; *b->last++ = '/'; *b->last++ = '/'; 488 *b->last++ = ':'; *b->last++ = '/'; *b->last++ = '/';
493 b->last = ngx_copy(b->last, host.data, host.len); 489 b->last = ngx_copy(b->last, host.data, host.len);
494 490
495 if (clcf->port_in_redirect) { 491 if (port) {
496 #if (NGX_HTTP_SSL) 492 b->last = ngx_sprintf(b->last, ":%ui", port);
497 if (r->connection->ssl) {
498 if (port != 443) {
499 b->last = ngx_copy(b->last, r->port_text->data,
500 r->port_text->len);
501 }
502 } else
503 #endif
504 {
505 if (port != 80) {
506 b->last = ngx_copy(b->last, r->port_text->data,
507 r->port_text->len);
508 }
509 }
510 } 493 }
511 494
512 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,
513 r->headers_out.location->value.len); 496 r->headers_out.location->value.len);
514 497