diff 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
line wrap: on
line diff
--- a/src/http/v2/ngx_http_v2_filter_module.c
+++ b/src/http/v2/ngx_http_v2_filter_module.c
@@ -137,10 +137,6 @@ ngx_http_v2_header_filter(ngx_http_reque
     ngx_http_v2_out_frame_t   *frame;
     ngx_http_core_loc_conf_t  *clcf;
     ngx_http_core_srv_conf_t  *cscf;
-    struct sockaddr_in        *sin;
-#if (NGX_HAVE_INET6)
-    struct sockaddr_in6       *sin6;
-#endif
     u_char                     addr[NGX_SOCKADDR_STRLEN];
 
     static const u_char nginx[5] = "\x84\xaa\x63\x55\xe7";
@@ -280,24 +276,7 @@ ngx_http_v2_header_filter(ngx_http_reque
                 }
             }
 
-            switch (fc->local_sockaddr->sa_family) {
-
-#if (NGX_HAVE_INET6)
-            case AF_INET6:
-                sin6 = (struct sockaddr_in6 *) fc->local_sockaddr;
-                port = ntohs(sin6->sin6_port);
-                break;
-#endif
-#if (NGX_HAVE_UNIX_DOMAIN)
-            case AF_UNIX:
-                port = 0;
-                break;
-#endif
-            default: /* AF_INET */
-                sin = (struct sockaddr_in *) fc->local_sockaddr;
-                port = ntohs(sin->sin_port);
-                break;
-            }
+            port = ngx_inet_get_port(fc->local_sockaddr);
 
             location.len = sizeof("https://") - 1 + host.len
                            + r->headers_out.location->value.len;