Mercurial > hg > nginx
comparison src/http/modules/ngx_http_geoip_module.c @ 8024:ef6a3a99a81a
Reworked multi headers to use linked lists.
Multi headers are now using linked lists instead of arrays. Notably,
the following fields were changed: r->headers_in.cookies (renamed
to r->headers_in.cookie), r->headers_in.x_forwarded_for,
r->headers_out.cache_control, r->headers_out.link, u->headers_in.cache_control
u->headers_in.cookies (renamed to u->headers_in.set_cookie).
The r->headers_in.cookies and u->headers_in.cookies fields were renamed
to r->headers_in.cookie and u->headers_in.set_cookie to match header names.
The ngx_http_parse_multi_header_lines() and ngx_http_parse_set_cookie_lines()
functions were changed accordingly.
With this change, multi headers are now essentially equivalent to normal
headers, and following changes will further make them equivalent.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 30 May 2022 21:25:33 +0300 |
parents | 2a288909abc6 |
children |
comparison
equal
deleted
inserted
replaced
8023:08b3ea81ff5f | 8024:ef6a3a99a81a |
---|---|
238 | 238 |
239 static u_long | 239 static u_long |
240 ngx_http_geoip_addr(ngx_http_request_t *r, ngx_http_geoip_conf_t *gcf) | 240 ngx_http_geoip_addr(ngx_http_request_t *r, ngx_http_geoip_conf_t *gcf) |
241 { | 241 { |
242 ngx_addr_t addr; | 242 ngx_addr_t addr; |
243 ngx_array_t *xfwd; | 243 ngx_table_elt_t *xfwd; |
244 struct sockaddr_in *sin; | 244 struct sockaddr_in *sin; |
245 | 245 |
246 addr.sockaddr = r->connection->sockaddr; | 246 addr.sockaddr = r->connection->sockaddr; |
247 addr.socklen = r->connection->socklen; | 247 addr.socklen = r->connection->socklen; |
248 /* addr.name = r->connection->addr_text; */ | 248 /* addr.name = r->connection->addr_text; */ |
249 | 249 |
250 xfwd = &r->headers_in.x_forwarded_for; | 250 xfwd = r->headers_in.x_forwarded_for; |
251 | 251 |
252 if (xfwd->nelts > 0 && gcf->proxies != NULL) { | 252 if (xfwd != NULL && gcf->proxies != NULL) { |
253 (void) ngx_http_get_forwarded_addr(r, &addr, xfwd, NULL, | 253 (void) ngx_http_get_forwarded_addr(r, &addr, xfwd, NULL, |
254 gcf->proxies, gcf->proxy_recursive); | 254 gcf->proxies, gcf->proxy_recursive); |
255 } | 255 } |
256 | 256 |
257 #if (NGX_HAVE_INET6) | 257 #if (NGX_HAVE_INET6) |
290 | 290 |
291 static geoipv6_t | 291 static geoipv6_t |
292 ngx_http_geoip_addr_v6(ngx_http_request_t *r, ngx_http_geoip_conf_t *gcf) | 292 ngx_http_geoip_addr_v6(ngx_http_request_t *r, ngx_http_geoip_conf_t *gcf) |
293 { | 293 { |
294 ngx_addr_t addr; | 294 ngx_addr_t addr; |
295 ngx_array_t *xfwd; | 295 ngx_table_elt_t *xfwd; |
296 in_addr_t addr4; | 296 in_addr_t addr4; |
297 struct in6_addr addr6; | 297 struct in6_addr addr6; |
298 struct sockaddr_in *sin; | 298 struct sockaddr_in *sin; |
299 struct sockaddr_in6 *sin6; | 299 struct sockaddr_in6 *sin6; |
300 | 300 |
301 addr.sockaddr = r->connection->sockaddr; | 301 addr.sockaddr = r->connection->sockaddr; |
302 addr.socklen = r->connection->socklen; | 302 addr.socklen = r->connection->socklen; |
303 /* addr.name = r->connection->addr_text; */ | 303 /* addr.name = r->connection->addr_text; */ |
304 | 304 |
305 xfwd = &r->headers_in.x_forwarded_for; | 305 xfwd = r->headers_in.x_forwarded_for; |
306 | 306 |
307 if (xfwd->nelts > 0 && gcf->proxies != NULL) { | 307 if (xfwd != NULL && gcf->proxies != NULL) { |
308 (void) ngx_http_get_forwarded_addr(r, &addr, xfwd, NULL, | 308 (void) ngx_http_get_forwarded_addr(r, &addr, xfwd, NULL, |
309 gcf->proxies, gcf->proxy_recursive); | 309 gcf->proxies, gcf->proxy_recursive); |
310 } | 310 } |
311 | 311 |
312 switch (addr.sockaddr->sa_family) { | 312 switch (addr.sockaddr->sa_family) { |