comparison src/http/v2/ngx_http_v2_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 155871d773cc
children 6f69e3c0f780
comparison
equal deleted inserted replaced
6592:2c7b488a61fb 6593:b3b7e33083ac
135 ngx_connection_t *fc; 135 ngx_connection_t *fc;
136 ngx_http_cleanup_t *cln; 136 ngx_http_cleanup_t *cln;
137 ngx_http_v2_out_frame_t *frame; 137 ngx_http_v2_out_frame_t *frame;
138 ngx_http_core_loc_conf_t *clcf; 138 ngx_http_core_loc_conf_t *clcf;
139 ngx_http_core_srv_conf_t *cscf; 139 ngx_http_core_srv_conf_t *cscf;
140 struct sockaddr_in *sin;
141 #if (NGX_HAVE_INET6)
142 struct sockaddr_in6 *sin6;
143 #endif
144 u_char addr[NGX_SOCKADDR_STRLEN]; 140 u_char addr[NGX_SOCKADDR_STRLEN];
145 141
146 static const u_char nginx[5] = "\x84\xaa\x63\x55\xe7"; 142 static const u_char nginx[5] = "\x84\xaa\x63\x55\xe7";
147 #if (NGX_HTTP_GZIP) 143 #if (NGX_HTTP_GZIP)
148 static const u_char accept_encoding[12] = 144 static const u_char accept_encoding[12] =
278 if (ngx_connection_local_sockaddr(fc, &host, 0) != NGX_OK) { 274 if (ngx_connection_local_sockaddr(fc, &host, 0) != NGX_OK) {
279 return NGX_ERROR; 275 return NGX_ERROR;
280 } 276 }
281 } 277 }
282 278
283 switch (fc->local_sockaddr->sa_family) { 279 port = ngx_inet_get_port(fc->local_sockaddr);
284
285 #if (NGX_HAVE_INET6)
286 case AF_INET6:
287 sin6 = (struct sockaddr_in6 *) fc->local_sockaddr;
288 port = ntohs(sin6->sin6_port);
289 break;
290 #endif
291 #if (NGX_HAVE_UNIX_DOMAIN)
292 case AF_UNIX:
293 port = 0;
294 break;
295 #endif
296 default: /* AF_INET */
297 sin = (struct sockaddr_in *) fc->local_sockaddr;
298 port = ntohs(sin->sin_port);
299 break;
300 }
301 280
302 location.len = sizeof("https://") - 1 + host.len 281 location.len = sizeof("https://") - 1 + host.len
303 + r->headers_out.location->value.len; 282 + r->headers_out.location->value.len;
304 283
305 if (clcf->port_in_redirect) { 284 if (clcf->port_in_redirect) {