comparison src/http/ngx_http_header_filter_module.c @ 6593:b3b7e33083ac

Introduced ngx_inet_get_port() and ngx_inet_set_port() functions.
author Roman Arutyunyan <arut@nginx.com>
date Mon, 20 Jun 2016 11:50:39 +0300
parents 654d2dae97d3
children d15172ebb400
comparison
equal deleted inserted replaced
6592:2c7b488a61fb 6593:b3b7e33083ac
159 ngx_list_part_t *part; 159 ngx_list_part_t *part;
160 ngx_table_elt_t *header; 160 ngx_table_elt_t *header;
161 ngx_connection_t *c; 161 ngx_connection_t *c;
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
168 u_char addr[NGX_SOCKADDR_STRLEN]; 164 u_char addr[NGX_SOCKADDR_STRLEN];
169 165
170 if (r->header_sent) { 166 if (r->header_sent) {
171 return NGX_OK; 167 return NGX_OK;
172 } 168 }
331 if (ngx_connection_local_sockaddr(c, &host, 0) != NGX_OK) { 327 if (ngx_connection_local_sockaddr(c, &host, 0) != NGX_OK) {
332 return NGX_ERROR; 328 return NGX_ERROR;
333 } 329 }
334 } 330 }
335 331
336 switch (c->local_sockaddr->sa_family) { 332 port = ngx_inet_get_port(c->local_sockaddr);
337
338 #if (NGX_HAVE_INET6)
339 case AF_INET6:
340 sin6 = (struct sockaddr_in6 *) c->local_sockaddr;
341 port = ntohs(sin6->sin6_port);
342 break;
343 #endif
344 #if (NGX_HAVE_UNIX_DOMAIN)
345 case AF_UNIX:
346 port = 0;
347 break;
348 #endif
349 default: /* AF_INET */
350 sin = (struct sockaddr_in *) c->local_sockaddr;
351 port = ntohs(sin->sin_port);
352 break;
353 }
354 333
355 len += sizeof("Location: https://") - 1 334 len += sizeof("Location: https://") - 1
356 + host.len 335 + host.len
357 + r->headers_out.location->value.len + 2; 336 + r->headers_out.location->value.len + 2;
358 337