Mercurial > hg > nginx-quic
comparison src/http/ngx_http_core_module.c @ 8903:8d0753760546 quic
Merged with the default branch.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 22 Jun 2022 18:34:58 +0400 |
parents | eaf356a35f5d 711737177b77 |
children | 6cf8ed15fd00 |
comparison
equal
deleted
inserted
replaced
8894:efbcdb9b37dc | 8903:8d0753760546 |
---|---|
1005 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); | 1005 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
1006 return NGX_OK; | 1006 return NGX_OK; |
1007 } | 1007 } |
1008 | 1008 |
1009 r->headers_out.location->hash = 1; | 1009 r->headers_out.location->hash = 1; |
1010 r->headers_out.location->next = NULL; | |
1010 ngx_str_set(&r->headers_out.location->key, "Location"); | 1011 ngx_str_set(&r->headers_out.location->key, "Location"); |
1011 | 1012 |
1012 if (r->args.len == 0) { | 1013 if (r->args.len == 0) { |
1013 r->headers_out.location->value = clcf->escaped_name; | 1014 r->headers_out.location->value = clcf->escaped_name; |
1014 | 1015 |
1085 | 1086 |
1086 ngx_int_t | 1087 ngx_int_t |
1087 ngx_http_core_access_phase(ngx_http_request_t *r, ngx_http_phase_handler_t *ph) | 1088 ngx_http_core_access_phase(ngx_http_request_t *r, ngx_http_phase_handler_t *ph) |
1088 { | 1089 { |
1089 ngx_int_t rc; | 1090 ngx_int_t rc; |
1091 ngx_table_elt_t *h; | |
1090 ngx_http_core_loc_conf_t *clcf; | 1092 ngx_http_core_loc_conf_t *clcf; |
1091 | 1093 |
1092 if (r != r->main) { | 1094 if (r != r->main) { |
1093 r->phase_handler = ph->next; | 1095 r->phase_handler = ph->next; |
1094 return NGX_AGAIN; | 1096 return NGX_AGAIN; |
1119 | 1121 |
1120 } else { | 1122 } else { |
1121 if (rc == NGX_OK) { | 1123 if (rc == NGX_OK) { |
1122 r->access_code = 0; | 1124 r->access_code = 0; |
1123 | 1125 |
1124 if (r->headers_out.www_authenticate) { | 1126 for (h = r->headers_out.www_authenticate; h; h = h->next) { |
1125 r->headers_out.www_authenticate->hash = 0; | 1127 h->hash = 0; |
1126 } | 1128 } |
1127 | 1129 |
1128 r->phase_handler = ph->next; | 1130 r->phase_handler = ph->next; |
1129 return NGX_AGAIN; | 1131 return NGX_AGAIN; |
1130 } | 1132 } |
1685 if (etag == NULL) { | 1687 if (etag == NULL) { |
1686 return NGX_ERROR; | 1688 return NGX_ERROR; |
1687 } | 1689 } |
1688 | 1690 |
1689 etag->hash = 1; | 1691 etag->hash = 1; |
1692 etag->next = NULL; | |
1690 ngx_str_set(&etag->key, "ETag"); | 1693 ngx_str_set(&etag->key, "ETag"); |
1691 | 1694 |
1692 etag->value.data = ngx_pnalloc(r->pool, NGX_OFF_T_LEN + NGX_TIME_T_LEN + 3); | 1695 etag->value.data = ngx_pnalloc(r->pool, NGX_OFF_T_LEN + NGX_TIME_T_LEN + 3); |
1693 if (etag->value.data == NULL) { | 1696 if (etag->value.data == NULL) { |
1694 etag->hash = 0; | 1697 etag->hash = 0; |
1779 if (r->headers_out.location == NULL) { | 1782 if (r->headers_out.location == NULL) { |
1780 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 1783 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
1781 } | 1784 } |
1782 | 1785 |
1783 r->headers_out.location->hash = 1; | 1786 r->headers_out.location->hash = 1; |
1787 r->headers_out.location->next = NULL; | |
1784 ngx_str_set(&r->headers_out.location->key, "Location"); | 1788 ngx_str_set(&r->headers_out.location->key, "Location"); |
1785 r->headers_out.location->value = val; | 1789 r->headers_out.location->value = val; |
1786 | 1790 |
1787 return status; | 1791 return status; |
1788 } | 1792 } |
2022 ngx_int_t | 2026 ngx_int_t |
2023 ngx_http_gzip_ok(ngx_http_request_t *r) | 2027 ngx_http_gzip_ok(ngx_http_request_t *r) |
2024 { | 2028 { |
2025 time_t date, expires; | 2029 time_t date, expires; |
2026 ngx_uint_t p; | 2030 ngx_uint_t p; |
2027 ngx_array_t *cc; | 2031 ngx_table_elt_t *e, *d, *ae, *cc; |
2028 ngx_table_elt_t *e, *d, *ae; | |
2029 ngx_http_core_loc_conf_t *clcf; | 2032 ngx_http_core_loc_conf_t *clcf; |
2030 | 2033 |
2031 r->gzip_tested = 1; | 2034 r->gzip_tested = 1; |
2032 | 2035 |
2033 if (r != r->main) { | 2036 if (r != r->main) { |
2116 } | 2119 } |
2117 | 2120 |
2118 return NGX_DECLINED; | 2121 return NGX_DECLINED; |
2119 } | 2122 } |
2120 | 2123 |
2121 cc = &r->headers_out.cache_control; | 2124 cc = r->headers_out.cache_control; |
2122 | 2125 |
2123 if (cc->elts) { | 2126 if (cc) { |
2124 | 2127 |
2125 if ((p & NGX_HTTP_GZIP_PROXIED_NO_CACHE) | 2128 if ((p & NGX_HTTP_GZIP_PROXIED_NO_CACHE) |
2126 && ngx_http_parse_multi_header_lines(cc, &ngx_http_gzip_no_cache, | 2129 && ngx_http_parse_multi_header_lines(r, cc, &ngx_http_gzip_no_cache, |
2127 NULL) | 2130 NULL) |
2128 >= 0) | 2131 != NULL) |
2129 { | 2132 { |
2130 goto ok; | 2133 goto ok; |
2131 } | 2134 } |
2132 | 2135 |
2133 if ((p & NGX_HTTP_GZIP_PROXIED_NO_STORE) | 2136 if ((p & NGX_HTTP_GZIP_PROXIED_NO_STORE) |
2134 && ngx_http_parse_multi_header_lines(cc, &ngx_http_gzip_no_store, | 2137 && ngx_http_parse_multi_header_lines(r, cc, &ngx_http_gzip_no_store, |
2135 NULL) | 2138 NULL) |
2136 >= 0) | 2139 != NULL) |
2137 { | 2140 { |
2138 goto ok; | 2141 goto ok; |
2139 } | 2142 } |
2140 | 2143 |
2141 if ((p & NGX_HTTP_GZIP_PROXIED_PRIVATE) | 2144 if ((p & NGX_HTTP_GZIP_PROXIED_PRIVATE) |
2142 && ngx_http_parse_multi_header_lines(cc, &ngx_http_gzip_private, | 2145 && ngx_http_parse_multi_header_lines(r, cc, &ngx_http_gzip_private, |
2143 NULL) | 2146 NULL) |
2144 >= 0) | 2147 != NULL) |
2145 { | 2148 { |
2146 goto ok; | 2149 goto ok; |
2147 } | 2150 } |
2148 | 2151 |
2149 return NGX_DECLINED; | 2152 return NGX_DECLINED; |
2710 } | 2713 } |
2711 | 2714 |
2712 | 2715 |
2713 ngx_int_t | 2716 ngx_int_t |
2714 ngx_http_get_forwarded_addr(ngx_http_request_t *r, ngx_addr_t *addr, | 2717 ngx_http_get_forwarded_addr(ngx_http_request_t *r, ngx_addr_t *addr, |
2715 ngx_array_t *headers, ngx_str_t *value, ngx_array_t *proxies, | 2718 ngx_table_elt_t *headers, ngx_str_t *value, ngx_array_t *proxies, |
2716 int recursive) | 2719 int recursive) |
2717 { | 2720 { |
2718 ngx_int_t rc; | 2721 ngx_int_t rc; |
2719 ngx_uint_t i, found; | 2722 ngx_uint_t found; |
2720 ngx_table_elt_t **h; | 2723 ngx_table_elt_t *h, *next; |
2721 | 2724 |
2722 if (headers == NULL) { | 2725 if (headers == NULL) { |
2723 return ngx_http_get_forwarded_addr_internal(r, addr, value->data, | 2726 return ngx_http_get_forwarded_addr_internal(r, addr, value->data, |
2724 value->len, proxies, | 2727 value->len, proxies, |
2725 recursive); | 2728 recursive); |
2726 } | 2729 } |
2727 | 2730 |
2728 i = headers->nelts; | 2731 /* revert headers order */ |
2729 h = headers->elts; | 2732 |
2733 for (h = headers, headers = NULL; h; h = next) { | |
2734 next = h->next; | |
2735 h->next = headers; | |
2736 headers = h; | |
2737 } | |
2738 | |
2739 /* iterate over all headers in reverse order */ | |
2730 | 2740 |
2731 rc = NGX_DECLINED; | 2741 rc = NGX_DECLINED; |
2732 | 2742 |
2733 found = 0; | 2743 found = 0; |
2734 | 2744 |
2735 while (i-- > 0) { | 2745 for (h = headers; h; h = h->next) { |
2736 rc = ngx_http_get_forwarded_addr_internal(r, addr, h[i]->value.data, | 2746 rc = ngx_http_get_forwarded_addr_internal(r, addr, h->value.data, |
2737 h[i]->value.len, proxies, | 2747 h->value.len, proxies, |
2738 recursive); | 2748 recursive); |
2739 | 2749 |
2740 if (!recursive) { | 2750 if (!recursive) { |
2741 break; | 2751 break; |
2742 } | 2752 } |
2749 if (rc != NGX_OK) { | 2759 if (rc != NGX_OK) { |
2750 break; | 2760 break; |
2751 } | 2761 } |
2752 | 2762 |
2753 found = 1; | 2763 found = 1; |
2764 } | |
2765 | |
2766 /* restore headers order */ | |
2767 | |
2768 for (h = headers, headers = NULL; h; h = next) { | |
2769 next = h->next; | |
2770 h->next = headers; | |
2771 headers = h; | |
2754 } | 2772 } |
2755 | 2773 |
2756 return rc; | 2774 return rc; |
2757 } | 2775 } |
2758 | 2776 |
2795 *addr = paddr; | 2813 *addr = paddr; |
2796 found = 1; | 2814 found = 1; |
2797 xfflen = p - 1 - xff; | 2815 xfflen = p - 1 - xff; |
2798 | 2816 |
2799 } while (recursive && p > xff); | 2817 } while (recursive && p > xff); |
2818 | |
2819 return NGX_OK; | |
2820 } | |
2821 | |
2822 | |
2823 ngx_int_t | |
2824 ngx_http_link_multi_headers(ngx_http_request_t *r) | |
2825 { | |
2826 ngx_uint_t i, j; | |
2827 ngx_list_part_t *part, *ppart; | |
2828 ngx_table_elt_t *header, *pheader, **ph; | |
2829 | |
2830 if (r->headers_in.multi_linked) { | |
2831 return NGX_OK; | |
2832 } | |
2833 | |
2834 r->headers_in.multi_linked = 1; | |
2835 | |
2836 part = &r->headers_in.headers.part; | |
2837 header = part->elts; | |
2838 | |
2839 for (i = 0; /* void */; i++) { | |
2840 | |
2841 if (i >= part->nelts) { | |
2842 if (part->next == NULL) { | |
2843 break; | |
2844 } | |
2845 | |
2846 part = part->next; | |
2847 header = part->elts; | |
2848 i = 0; | |
2849 } | |
2850 | |
2851 header[i].next = NULL; | |
2852 | |
2853 /* | |
2854 * search for previous headers with the same name; | |
2855 * if there are any, link to them | |
2856 */ | |
2857 | |
2858 ppart = &r->headers_in.headers.part; | |
2859 pheader = ppart->elts; | |
2860 | |
2861 for (j = 0; /* void */; j++) { | |
2862 | |
2863 if (j >= ppart->nelts) { | |
2864 if (ppart->next == NULL) { | |
2865 break; | |
2866 } | |
2867 | |
2868 ppart = ppart->next; | |
2869 pheader = ppart->elts; | |
2870 j = 0; | |
2871 } | |
2872 | |
2873 if (part == ppart && i == j) { | |
2874 break; | |
2875 } | |
2876 | |
2877 if (header[i].key.len == pheader[j].key.len | |
2878 && ngx_strncasecmp(header[i].key.data, pheader[j].key.data, | |
2879 header[i].key.len) | |
2880 == 0) | |
2881 { | |
2882 ph = &pheader[j].next; | |
2883 while (*ph) { ph = &(*ph)->next; } | |
2884 *ph = &header[i]; | |
2885 | |
2886 r->headers_in.multi = 1; | |
2887 | |
2888 break; | |
2889 } | |
2890 } | |
2891 } | |
2800 | 2892 |
2801 return NGX_OK; | 2893 return NGX_OK; |
2802 } | 2894 } |
2803 | 2895 |
2804 | 2896 |