Mercurial > hg > nginx
comparison src/http/ngx_http_request.c @ 8025:c263f9ffa1fd
All non-unique input headers are now linked lists.
The ngx_http_process_multi_header_lines() function is removed, as it is
exactly equivalent to ngx_http_process_header_line(). Similarly,
ngx_http_variable_header() is used instead of ngx_http_variable_headers().
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 30 May 2022 21:25:35 +0300 |
parents | ef6a3a99a81a |
children | cffaf3f2eec8 8d0753760546 |
comparison
equal
deleted
inserted
replaced
8024:ef6a3a99a81a | 8025:c263f9ffa1fd |
---|---|
20 | 20 |
21 static ngx_int_t ngx_http_process_header_line(ngx_http_request_t *r, | 21 static ngx_int_t ngx_http_process_header_line(ngx_http_request_t *r, |
22 ngx_table_elt_t *h, ngx_uint_t offset); | 22 ngx_table_elt_t *h, ngx_uint_t offset); |
23 static ngx_int_t ngx_http_process_unique_header_line(ngx_http_request_t *r, | 23 static ngx_int_t ngx_http_process_unique_header_line(ngx_http_request_t *r, |
24 ngx_table_elt_t *h, ngx_uint_t offset); | 24 ngx_table_elt_t *h, ngx_uint_t offset); |
25 static ngx_int_t ngx_http_process_multi_header_lines(ngx_http_request_t *r, | |
26 ngx_table_elt_t *h, ngx_uint_t offset); | |
27 static ngx_int_t ngx_http_process_host(ngx_http_request_t *r, | 25 static ngx_int_t ngx_http_process_host(ngx_http_request_t *r, |
28 ngx_table_elt_t *h, ngx_uint_t offset); | 26 ngx_table_elt_t *h, ngx_uint_t offset); |
29 static ngx_int_t ngx_http_process_connection(ngx_http_request_t *r, | 27 static ngx_int_t ngx_http_process_connection(ngx_http_request_t *r, |
30 ngx_table_elt_t *h, ngx_uint_t offset); | 28 ngx_table_elt_t *h, ngx_uint_t offset); |
31 static ngx_int_t ngx_http_process_user_agent(ngx_http_request_t *r, | 29 static ngx_int_t ngx_http_process_user_agent(ngx_http_request_t *r, |
162 ngx_http_process_header_line }, | 160 ngx_http_process_header_line }, |
163 | 161 |
164 #if (NGX_HTTP_X_FORWARDED_FOR) | 162 #if (NGX_HTTP_X_FORWARDED_FOR) |
165 { ngx_string("X-Forwarded-For"), | 163 { ngx_string("X-Forwarded-For"), |
166 offsetof(ngx_http_headers_in_t, x_forwarded_for), | 164 offsetof(ngx_http_headers_in_t, x_forwarded_for), |
167 ngx_http_process_multi_header_lines }, | 165 ngx_http_process_header_line }, |
168 #endif | 166 #endif |
169 | 167 |
170 #if (NGX_HTTP_REALIP) | 168 #if (NGX_HTTP_REALIP) |
171 { ngx_string("X-Real-IP"), | 169 { ngx_string("X-Real-IP"), |
172 offsetof(ngx_http_headers_in_t, x_real_ip), | 170 offsetof(ngx_http_headers_in_t, x_real_ip), |
195 { ngx_string("Date"), offsetof(ngx_http_headers_in_t, date), | 193 { ngx_string("Date"), offsetof(ngx_http_headers_in_t, date), |
196 ngx_http_process_header_line }, | 194 ngx_http_process_header_line }, |
197 #endif | 195 #endif |
198 | 196 |
199 { ngx_string("Cookie"), offsetof(ngx_http_headers_in_t, cookie), | 197 { ngx_string("Cookie"), offsetof(ngx_http_headers_in_t, cookie), |
200 ngx_http_process_multi_header_lines }, | 198 ngx_http_process_header_line }, |
201 | 199 |
202 { ngx_null_string, 0, NULL } | 200 { ngx_null_string, 0, NULL } |
203 }; | 201 }; |
204 | 202 |
205 | 203 |
1740 { | 1738 { |
1741 ngx_table_elt_t **ph; | 1739 ngx_table_elt_t **ph; |
1742 | 1740 |
1743 ph = (ngx_table_elt_t **) ((char *) &r->headers_in + offset); | 1741 ph = (ngx_table_elt_t **) ((char *) &r->headers_in + offset); |
1744 | 1742 |
1745 if (*ph == NULL) { | 1743 while (*ph) { ph = &(*ph)->next; } |
1746 *ph = h; | 1744 |
1747 h->next = NULL; | 1745 *ph = h; |
1748 } | 1746 h->next = NULL; |
1749 | 1747 |
1750 return NGX_OK; | 1748 return NGX_OK; |
1751 } | 1749 } |
1752 | 1750 |
1753 | 1751 |
1849 ngx_http_process_user_agent(ngx_http_request_t *r, ngx_table_elt_t *h, | 1847 ngx_http_process_user_agent(ngx_http_request_t *r, ngx_table_elt_t *h, |
1850 ngx_uint_t offset) | 1848 ngx_uint_t offset) |
1851 { | 1849 { |
1852 u_char *user_agent, *msie; | 1850 u_char *user_agent, *msie; |
1853 | 1851 |
1854 if (r->headers_in.user_agent) { | 1852 if (ngx_http_process_header_line(r, h, offset) != NGX_OK) { |
1855 return NGX_OK; | 1853 return NGX_ERROR; |
1856 } | 1854 } |
1857 | |
1858 r->headers_in.user_agent = h; | |
1859 h->next = NULL; | |
1860 | 1855 |
1861 /* check some widespread browsers while the header is in CPU cache */ | 1856 /* check some widespread browsers while the header is in CPU cache */ |
1862 | 1857 |
1863 user_agent = h->value.data; | 1858 user_agent = h->value.data; |
1864 | 1859 |
1912 | 1907 |
1913 } else if (ngx_strstrn(user_agent, "Konqueror", 9 - 1)) { | 1908 } else if (ngx_strstrn(user_agent, "Konqueror", 9 - 1)) { |
1914 r->headers_in.konqueror = 1; | 1909 r->headers_in.konqueror = 1; |
1915 } | 1910 } |
1916 } | 1911 } |
1917 | |
1918 return NGX_OK; | |
1919 } | |
1920 | |
1921 | |
1922 static ngx_int_t | |
1923 ngx_http_process_multi_header_lines(ngx_http_request_t *r, ngx_table_elt_t *h, | |
1924 ngx_uint_t offset) | |
1925 { | |
1926 ngx_table_elt_t **ph; | |
1927 | |
1928 ph = (ngx_table_elt_t **) ((char *) &r->headers_in + offset); | |
1929 | |
1930 while (*ph) { ph = &(*ph)->next; } | |
1931 | |
1932 *ph = h; | |
1933 h->next = NULL; | |
1934 | 1912 |
1935 return NGX_OK; | 1913 return NGX_OK; |
1936 } | 1914 } |
1937 | 1915 |
1938 | 1916 |