Mercurial > hg > nginx
comparison src/http/v2/ngx_http_v2_filter_module.c @ 7296:8e6bb4e6045f
HTTP/2: use scheme from original request for pushes (closes #1549).
Instead of the connection scheme, use scheme from the original request.
This fixes pushes when SSL is terminated by a proxy server in front of
nginx.
author | Ruslan Ermilov <ru@nginx.com> |
---|---|
date | Thu, 07 Jun 2018 20:04:22 +0300 |
parents | 190591ab0d76 |
children | 01e26357916a 99b6733876c4 |
comparison
equal
deleted
inserted
replaced
7295:89430899c72a | 7296:8e6bb4e6045f |
---|---|
942 return NGX_ABORT; | 942 return NGX_ABORT; |
943 } | 943 } |
944 | 944 |
945 ph = ngx_http_v2_push_headers; | 945 ph = ngx_http_v2_push_headers; |
946 | 946 |
947 len = ngx_max(r->schema.len, path->len); | |
948 | |
947 if (binary[0].len) { | 949 if (binary[0].len) { |
948 tmp = ngx_palloc(r->pool, path->len); | |
949 if (tmp == NULL) { | |
950 return NGX_ERROR; | |
951 } | |
952 | |
953 } else { | |
954 len = path->len; | |
955 | |
956 for (i = 0; i < NGX_HTTP_V2_PUSH_HEADERS; i++) { | |
957 h = (ngx_table_elt_t **) ((char *) &r->headers_in + ph[i].offset); | |
958 | |
959 if (*h) { | |
960 len = ngx_max(len, (*h)->value.len); | |
961 } | |
962 } | |
963 | |
964 tmp = ngx_palloc(r->pool, len); | 950 tmp = ngx_palloc(r->pool, len); |
965 if (tmp == NULL) { | 951 if (tmp == NULL) { |
966 return NGX_ERROR; | 952 return NGX_ERROR; |
967 } | 953 } |
968 | 954 |
955 } else { | |
956 for (i = 0; i < NGX_HTTP_V2_PUSH_HEADERS; i++) { | |
957 h = (ngx_table_elt_t **) ((char *) &r->headers_in + ph[i].offset); | |
958 | |
959 if (*h) { | |
960 len = ngx_max(len, (*h)->value.len); | |
961 } | |
962 } | |
963 | |
964 tmp = ngx_palloc(r->pool, len); | |
965 if (tmp == NULL) { | |
966 return NGX_ERROR; | |
967 } | |
968 | |
969 for (i = 0; i < NGX_HTTP_V2_PUSH_HEADERS; i++) { | 969 for (i = 0; i < NGX_HTTP_V2_PUSH_HEADERS; i++) { |
970 h = (ngx_table_elt_t **) ((char *) &r->headers_in + ph[i].offset); | 970 h = (ngx_table_elt_t **) ((char *) &r->headers_in + ph[i].offset); |
971 | 971 |
972 if (*h == NULL) { | 972 if (*h == NULL) { |
973 continue; | 973 continue; |
992 } | 992 } |
993 | 993 |
994 len = (h2c->table_update ? 1 : 0) | 994 len = (h2c->table_update ? 1 : 0) |
995 + 1 | 995 + 1 |
996 + 1 + NGX_HTTP_V2_INT_OCTETS + path->len | 996 + 1 + NGX_HTTP_V2_INT_OCTETS + path->len |
997 + 1; | 997 + 1 + NGX_HTTP_V2_INT_OCTETS + r->schema.len; |
998 | 998 |
999 for (i = 0; i < NGX_HTTP_V2_PUSH_HEADERS; i++) { | 999 for (i = 0; i < NGX_HTTP_V2_PUSH_HEADERS; i++) { |
1000 len += binary[i].len; | 1000 len += binary[i].len; |
1001 } | 1001 } |
1002 | 1002 |
1023 "http2 push header: \":path: %V\"", path); | 1023 "http2 push header: \":path: %V\"", path); |
1024 | 1024 |
1025 *pos++ = ngx_http_v2_inc_indexed(NGX_HTTP_V2_PATH_INDEX); | 1025 *pos++ = ngx_http_v2_inc_indexed(NGX_HTTP_V2_PATH_INDEX); |
1026 pos = ngx_http_v2_write_value(pos, path->data, path->len, tmp); | 1026 pos = ngx_http_v2_write_value(pos, path->data, path->len, tmp); |
1027 | 1027 |
1028 #if (NGX_HTTP_SSL) | 1028 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, fc->log, 0, |
1029 if (fc->ssl) { | 1029 "http2 push header: \":scheme: %V\"", &r->schema); |
1030 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, fc->log, 0, | 1030 |
1031 "http2 push header: \":scheme: https\""); | 1031 if (r->schema.len == 5 && ngx_strncmp(r->schema.data, "https", 5) == 0) { |
1032 *pos++ = ngx_http_v2_indexed(NGX_HTTP_V2_SCHEME_HTTPS_INDEX); | 1032 *pos++ = ngx_http_v2_indexed(NGX_HTTP_V2_SCHEME_HTTPS_INDEX); |
1033 | 1033 |
1034 } else | 1034 } else if (r->schema.len == 4 |
1035 #endif | 1035 && ngx_strncmp(r->schema.data, "http", 4) == 0) |
1036 { | 1036 { |
1037 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, fc->log, 0, | |
1038 "http2 push header: \":scheme: http\""); | |
1039 *pos++ = ngx_http_v2_indexed(NGX_HTTP_V2_SCHEME_HTTP_INDEX); | 1037 *pos++ = ngx_http_v2_indexed(NGX_HTTP_V2_SCHEME_HTTP_INDEX); |
1038 | |
1039 } else { | |
1040 *pos++ = ngx_http_v2_inc_indexed(NGX_HTTP_V2_SCHEME_HTTP_INDEX); | |
1041 pos = ngx_http_v2_write_value(pos, r->schema.data, r->schema.len, tmp); | |
1040 } | 1042 } |
1041 | 1043 |
1042 for (i = 0; i < NGX_HTTP_V2_PUSH_HEADERS; i++) { | 1044 for (i = 0; i < NGX_HTTP_V2_PUSH_HEADERS; i++) { |
1043 h = (ngx_table_elt_t **) ((char *) &r->headers_in + ph[i].offset); | 1045 h = (ngx_table_elt_t **) ((char *) &r->headers_in + ph[i].offset); |
1044 | 1046 |