annotate src/http/modules/ngx_http_map_module.c @ 7746:88eca63261c3

gRPC: RST_STREAM(NO_ERROR) handling after "trailer only" responses. Similarly to the problem fixed in 2096b21fcd10 (ticket #1792), when a "trailer only" gRPC response (that is, a response with the END_STREAM flag in the HEADERS frame) was immediately followed by RST_STREAM(NO_ERROR) in the data preread along with the response header, RST_STREAM wasn't properly skipped and caused "upstream rejected request with error 0" errors. Observed with "unknown service" gRPC errors returned by grpc-go. Fix is to set ctx->done if we are going to parse additional data, so the RST_STREAM(NO_ERROR) is properly skipped. Additionally, now ngx_http_grpc_filter() will complain about frames sent for closed stream if there are any.
author Pavel Pautov <p.pautov@f5.com>
date Wed, 18 Nov 2020 18:41:16 -0800
parents ec10ce307dc0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
2 /*
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
3 * Copyright (C) Igor Sysoev
4412
d620f497c50f Copyright updated.
Maxim Konovalov <maxim@nginx.com>
parents: 3930
diff changeset
4 * Copyright (C) Nginx, Inc.
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
5 */
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
6
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
7
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
8 #include <ngx_config.h>
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
9 #include <ngx_core.h>
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
10 #include <ngx_http.h>
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
11
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
12
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
13 typedef struct {
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
14 ngx_uint_t hash_max_size;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
15 ngx_uint_t hash_bucket_size;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
16 } ngx_http_map_conf_t;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
17
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
18
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
19 typedef struct {
593
425af804d968 nginx-0.3.18-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 591
diff changeset
20 ngx_hash_keys_arrays_t keys;
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
21
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
22 ngx_array_t *values_hash;
3872
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
23 #if (NGX_PCRE)
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
24 ngx_array_t regexes;
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
25 #endif
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
26
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
27 ngx_http_variable_value_t *default_value;
3792
164a7f8df979 allow variable as "map" value
Igor Sysoev <igor@sysoev.ru>
parents: 3791
diff changeset
28 ngx_conf_t *cf;
6832
ec10ce307dc0 Map: the "volatile" parameter.
Ruslan Ermilov <ru@nginx.com>
parents: 6831
diff changeset
29 unsigned hostnames:1;
ec10ce307dc0 Map: the "volatile" parameter.
Ruslan Ermilov <ru@nginx.com>
parents: 6831
diff changeset
30 unsigned no_cacheable:1;
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
31 } ngx_http_map_conf_ctx_t;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
32
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
33
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
34 typedef struct {
3872
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
35 ngx_http_map_t map;
3789
19c931be8b98 allow expressions in the first "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3642
diff changeset
36 ngx_http_complex_value_t value;
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
37 ngx_http_variable_value_t *default_value;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
38 ngx_uint_t hostnames; /* unsigned hostnames:1 */
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
39 } ngx_http_map_ctx_t;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
40
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
41
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
42 static int ngx_libc_cdecl ngx_http_map_cmp_dns_wildcards(const void *one,
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
43 const void *two);
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
44 static void *ngx_http_map_create_conf(ngx_conf_t *cf);
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
45 static char *ngx_http_map_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
46 static char *ngx_http_map(ngx_conf_t *cf, ngx_command_t *dummy, void *conf);
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
47
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
48
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
49 static ngx_command_t ngx_http_map_commands[] = {
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
50
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
51 { ngx_string("map"),
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
52 NGX_HTTP_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_TAKE2,
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
53 ngx_http_map_block,
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
54 NGX_HTTP_MAIN_CONF_OFFSET,
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
55 0,
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
56 NULL },
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
57
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
58 { ngx_string("map_hash_max_size"),
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
59 NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1,
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
60 ngx_conf_set_num_slot,
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
61 NGX_HTTP_MAIN_CONF_OFFSET,
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
62 offsetof(ngx_http_map_conf_t, hash_max_size),
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
63 NULL },
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
64
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
65 { ngx_string("map_hash_bucket_size"),
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
66 NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1,
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
67 ngx_conf_set_num_slot,
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
68 NGX_HTTP_MAIN_CONF_OFFSET,
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
69 offsetof(ngx_http_map_conf_t, hash_bucket_size),
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
70 NULL },
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
71
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
72 ngx_null_command
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
73 };
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
74
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
75
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
76 static ngx_http_module_t ngx_http_map_module_ctx = {
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
77 NULL, /* preconfiguration */
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
78 NULL, /* postconfiguration */
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
79
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
80 ngx_http_map_create_conf, /* create main configuration */
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
81 NULL, /* init main configuration */
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
82
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
83 NULL, /* create server configuration */
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
84 NULL, /* merge server configuration */
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
85
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
86 NULL, /* create location configuration */
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
87 NULL /* merge location configuration */
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
88 };
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
89
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
90
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
91 ngx_module_t ngx_http_map_module = {
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
92 NGX_MODULE_V1,
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
93 &ngx_http_map_module_ctx, /* module context */
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
94 ngx_http_map_commands, /* module directives */
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
95 NGX_HTTP_MODULE, /* module type */
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
96 NULL, /* init master */
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
97 NULL, /* init module */
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
98 NULL, /* init process */
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
99 NULL, /* init thread */
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
100 NULL, /* exit thread */
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
101 NULL, /* exit process */
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
102 NULL, /* exit master */
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
103 NGX_MODULE_V1_PADDING
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
104 };
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
105
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
106
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
107 static ngx_int_t
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
108 ngx_http_map_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v,
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
109 uintptr_t data)
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
110 {
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
111 ngx_http_map_ctx_t *map = (ngx_http_map_ctx_t *) data;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
112
6535
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
113 ngx_str_t val, str;
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
114 ngx_http_complex_value_t *cv;
3789
19c931be8b98 allow expressions in the first "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3642
diff changeset
115 ngx_http_variable_value_t *value;
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
116
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
117 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
118 "http map started");
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
119
3789
19c931be8b98 allow expressions in the first "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3642
diff changeset
120 if (ngx_http_complex_value(r, &map->value, &val) != NGX_OK) {
19c931be8b98 allow expressions in the first "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3642
diff changeset
121 return NGX_ERROR;
797
36f7b549f481 fix segfault if $server_addr failed
Igor Sysoev <igor@sysoev.ru>
parents: 637
diff changeset
122 }
36f7b549f481 fix segfault if $server_addr failed
Igor Sysoev <igor@sysoev.ru>
parents: 637
diff changeset
123
4712
fd3eefefa5f9 map: strip final dot before looking up in a map of hostnames.
Ruslan Ermilov <ru@nginx.com>
parents: 4412
diff changeset
124 if (map->hostnames && val.len > 0 && val.data[val.len - 1] == '.') {
fd3eefefa5f9 map: strip final dot before looking up in a map of hostnames.
Ruslan Ermilov <ru@nginx.com>
parents: 4412
diff changeset
125 val.len--;
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
126 }
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
127
3929
fa4612bfb9fa change ngx_http_map_find(): use case sensitive regexes
Igor Sysoev <igor@sysoev.ru>
parents: 3874
diff changeset
128 value = ngx_http_map_find(r, &map->map, &val);
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
129
3792
164a7f8df979 allow variable as "map" value
Igor Sysoev <igor@sysoev.ru>
parents: 3791
diff changeset
130 if (value == NULL) {
164a7f8df979 allow variable as "map" value
Igor Sysoev <igor@sysoev.ru>
parents: 3791
diff changeset
131 value = map->default_value;
164a7f8df979 allow variable as "map" value
Igor Sysoev <igor@sysoev.ru>
parents: 3791
diff changeset
132 }
164a7f8df979 allow variable as "map" value
Igor Sysoev <igor@sysoev.ru>
parents: 3791
diff changeset
133
164a7f8df979 allow variable as "map" value
Igor Sysoev <igor@sysoev.ru>
parents: 3791
diff changeset
134 if (!value->valid) {
6535
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
135 cv = (ngx_http_complex_value_t *) value->data;
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
136
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
137 if (ngx_http_complex_value(r, cv, &str) != NGX_OK) {
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
138 return NGX_ERROR;
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
139 }
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
140
6535
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
141 v->valid = 1;
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
142 v->no_cacheable = 0;
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
143 v->not_found = 0;
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
144 v->len = str.len;
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
145 v->data = str.data;
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
146
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
147 } else {
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
148 *v = *value;
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
149 }
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
150
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
151 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
6480
f01ab2dbcfdc Fixed logging.
Sergey Kandaurov <pluknet@nginx.com>
parents: 6230
diff changeset
152 "http map: \"%V\" \"%v\"", &val, v);
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
153
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
154 return NGX_OK;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
155 }
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
156
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
157
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
158 static void *
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
159 ngx_http_map_create_conf(ngx_conf_t *cf)
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
160 {
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
161 ngx_http_map_conf_t *mcf;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
162
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
163 mcf = ngx_palloc(cf->pool, sizeof(ngx_http_map_conf_t));
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
164 if (mcf == NULL) {
2912
c7d57b539248 return NULL instead of NGX_CONF_ERROR on a create conf failure
Igor Sysoev <igor@sysoev.ru>
parents: 2536
diff changeset
165 return NULL;
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
166 }
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
167
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
168 mcf->hash_max_size = NGX_CONF_UNSET_UINT;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
169 mcf->hash_bucket_size = NGX_CONF_UNSET_UINT;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
170
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
171 return mcf;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
172 }
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
173
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
174
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
175 static char *
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
176 ngx_http_map_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
177 {
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
178 ngx_http_map_conf_t *mcf = conf;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
179
3789
19c931be8b98 allow expressions in the first "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3642
diff changeset
180 char *rv;
19c931be8b98 allow expressions in the first "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3642
diff changeset
181 ngx_str_t *value, name;
19c931be8b98 allow expressions in the first "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3642
diff changeset
182 ngx_conf_t save;
19c931be8b98 allow expressions in the first "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3642
diff changeset
183 ngx_pool_t *pool;
19c931be8b98 allow expressions in the first "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3642
diff changeset
184 ngx_hash_init_t hash;
19c931be8b98 allow expressions in the first "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3642
diff changeset
185 ngx_http_map_ctx_t *map;
19c931be8b98 allow expressions in the first "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3642
diff changeset
186 ngx_http_variable_t *var;
19c931be8b98 allow expressions in the first "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3642
diff changeset
187 ngx_http_map_conf_ctx_t ctx;
19c931be8b98 allow expressions in the first "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3642
diff changeset
188 ngx_http_compile_complex_value_t ccv;
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
189
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
190 if (mcf->hash_max_size == NGX_CONF_UNSET_UINT) {
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
191 mcf->hash_max_size = 2048;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
192 }
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
193
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
194 if (mcf->hash_bucket_size == NGX_CONF_UNSET_UINT) {
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
195 mcf->hash_bucket_size = ngx_cacheline_size;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
196
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
197 } else {
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
198 mcf->hash_bucket_size = ngx_align(mcf->hash_bucket_size,
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
199 ngx_cacheline_size);
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
200 }
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
201
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
202 map = ngx_pcalloc(cf->pool, sizeof(ngx_http_map_ctx_t));
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
203 if (map == NULL) {
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
204 return NGX_CONF_ERROR;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
205 }
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
206
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
207 value = cf->args->elts;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
208
3789
19c931be8b98 allow expressions in the first "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3642
diff changeset
209 ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t));
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
210
3789
19c931be8b98 allow expressions in the first "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3642
diff changeset
211 ccv.cf = cf;
19c931be8b98 allow expressions in the first "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3642
diff changeset
212 ccv.value = &value[1];
19c931be8b98 allow expressions in the first "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3642
diff changeset
213 ccv.complex_value = &map->value;
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
214
3789
19c931be8b98 allow expressions in the first "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3642
diff changeset
215 if (ngx_http_compile_complex_value(&ccv) != NGX_OK) {
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
216 return NGX_CONF_ERROR;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
217 }
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
218
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
219 name = value[2];
4972
8b635cf36ccc Added checks that disallow adding a variable with an empty name.
Ruslan Ermilov <ru@nginx.com>
parents: 4827
diff changeset
220
8b635cf36ccc Added checks that disallow adding a variable with an empty name.
Ruslan Ermilov <ru@nginx.com>
parents: 4827
diff changeset
221 if (name.data[0] != '$') {
8b635cf36ccc Added checks that disallow adding a variable with an empty name.
Ruslan Ermilov <ru@nginx.com>
parents: 4827
diff changeset
222 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
8b635cf36ccc Added checks that disallow adding a variable with an empty name.
Ruslan Ermilov <ru@nginx.com>
parents: 4827
diff changeset
223 "invalid variable name \"%V\"", &name);
8b635cf36ccc Added checks that disallow adding a variable with an empty name.
Ruslan Ermilov <ru@nginx.com>
parents: 4827
diff changeset
224 return NGX_CONF_ERROR;
8b635cf36ccc Added checks that disallow adding a variable with an empty name.
Ruslan Ermilov <ru@nginx.com>
parents: 4827
diff changeset
225 }
8b635cf36ccc Added checks that disallow adding a variable with an empty name.
Ruslan Ermilov <ru@nginx.com>
parents: 4827
diff changeset
226
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
227 name.len--;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
228 name.data++;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
229
1565
4c43e25d11ea fix English grammar
Igor Sysoev <igor@sysoev.ru>
parents: 1406
diff changeset
230 var = ngx_http_add_variable(cf, &name, NGX_HTTP_VAR_CHANGEABLE);
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
231 if (var == NULL) {
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
232 return NGX_CONF_ERROR;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
233 }
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
234
637
e60fe4cf1d4e nginx-0.3.40-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 593
diff changeset
235 var->get_handler = ngx_http_map_variable;
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
236 var->data = (uintptr_t) map;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
237
5124
5482671df278 Use NGX_DEFAULT_POOL_SIZE macro where appropriate.
Ruslan Ermilov <ru@nginx.com>
parents: 4972
diff changeset
238 pool = ngx_create_pool(NGX_DEFAULT_POOL_SIZE, cf->log);
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
239 if (pool == NULL) {
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
240 return NGX_CONF_ERROR;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
241 }
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
242
593
425af804d968 nginx-0.3.18-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 591
diff changeset
243 ctx.keys.pool = cf->pool;
425af804d968 nginx-0.3.18-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 591
diff changeset
244 ctx.keys.temp_pool = pool;
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
245
593
425af804d968 nginx-0.3.18-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 591
diff changeset
246 if (ngx_hash_keys_array_init(&ctx.keys, NGX_HASH_LARGE) != NGX_OK) {
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
247 ngx_destroy_pool(pool);
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
248 return NGX_CONF_ERROR;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
249 }
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
250
593
425af804d968 nginx-0.3.18-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 591
diff changeset
251 ctx.values_hash = ngx_pcalloc(pool, sizeof(ngx_array_t) * ctx.keys.hsize);
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
252 if (ctx.values_hash == NULL) {
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
253 ngx_destroy_pool(pool);
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
254 return NGX_CONF_ERROR;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
255 }
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
256
3872
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
257 #if (NGX_PCRE)
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
258 if (ngx_array_init(&ctx.regexes, cf->pool, 2, sizeof(ngx_http_map_regex_t))
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
259 != NGX_OK)
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
260 {
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
261 ngx_destroy_pool(pool);
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
262 return NGX_CONF_ERROR;
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
263 }
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
264 #endif
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
265
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
266 ctx.default_value = NULL;
3792
164a7f8df979 allow variable as "map" value
Igor Sysoev <igor@sysoev.ru>
parents: 3791
diff changeset
267 ctx.cf = &save;
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
268 ctx.hostnames = 0;
6832
ec10ce307dc0 Map: the "volatile" parameter.
Ruslan Ermilov <ru@nginx.com>
parents: 6831
diff changeset
269 ctx.no_cacheable = 0;
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
270
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
271 save = *cf;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
272 cf->pool = pool;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
273 cf->ctx = &ctx;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
274 cf->handler = ngx_http_map;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
275 cf->handler_conf = conf;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
276
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
277 rv = ngx_conf_parse(cf, NULL);
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
278
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
279 *cf = save;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
280
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
281 if (rv != NGX_CONF_OK) {
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
282 ngx_destroy_pool(pool);
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
283 return rv;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
284 }
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
285
6832
ec10ce307dc0 Map: the "volatile" parameter.
Ruslan Ermilov <ru@nginx.com>
parents: 6831
diff changeset
286 if (ctx.no_cacheable) {
ec10ce307dc0 Map: the "volatile" parameter.
Ruslan Ermilov <ru@nginx.com>
parents: 6831
diff changeset
287 var->flags |= NGX_HTTP_VAR_NOCACHEABLE;
ec10ce307dc0 Map: the "volatile" parameter.
Ruslan Ermilov <ru@nginx.com>
parents: 6831
diff changeset
288 }
ec10ce307dc0 Map: the "volatile" parameter.
Ruslan Ermilov <ru@nginx.com>
parents: 6831
diff changeset
289
1253
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
290 map->default_value = ctx.default_value ? ctx.default_value:
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
291 &ngx_http_variable_null_value;
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
292
4712
fd3eefefa5f9 map: strip final dot before looking up in a map of hostnames.
Ruslan Ermilov <ru@nginx.com>
parents: 4412
diff changeset
293 map->hostnames = ctx.hostnames;
fd3eefefa5f9 map: strip final dot before looking up in a map of hostnames.
Ruslan Ermilov <ru@nginx.com>
parents: 4412
diff changeset
294
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
295 hash.key = ngx_hash_key_lc;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
296 hash.max_size = mcf->hash_max_size;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
297 hash.bucket_size = mcf->hash_bucket_size;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
298 hash.name = "map_hash";
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
299 hash.pool = cf->pool;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
300
593
425af804d968 nginx-0.3.18-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 591
diff changeset
301 if (ctx.keys.keys.nelts) {
3872
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
302 hash.hash = &map->map.hash.hash;
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
303 hash.temp_pool = NULL;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
304
593
425af804d968 nginx-0.3.18-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 591
diff changeset
305 if (ngx_hash_init(&hash, ctx.keys.keys.elts, ctx.keys.keys.nelts)
591
8c0cdd81580e nginx-0.3.17-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 589
diff changeset
306 != NGX_OK)
8c0cdd81580e nginx-0.3.17-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 589
diff changeset
307 {
593
425af804d968 nginx-0.3.18-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 591
diff changeset
308 ngx_destroy_pool(pool);
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
309 return NGX_CONF_ERROR;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
310 }
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
311 }
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
312
1253
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
313 if (ctx.keys.dns_wc_head.nelts) {
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
314
1253
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
315 ngx_qsort(ctx.keys.dns_wc_head.elts,
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
316 (size_t) ctx.keys.dns_wc_head.nelts,
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
317 sizeof(ngx_hash_key_t), ngx_http_map_cmp_dns_wildcards);
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
318
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
319 hash.hash = NULL;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
320 hash.temp_pool = pool;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
321
1253
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
322 if (ngx_hash_wildcard_init(&hash, ctx.keys.dns_wc_head.elts,
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
323 ctx.keys.dns_wc_head.nelts)
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
324 != NGX_OK)
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
325 {
593
425af804d968 nginx-0.3.18-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 591
diff changeset
326 ngx_destroy_pool(pool);
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
327 return NGX_CONF_ERROR;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
328 }
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
329
3872
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
330 map->map.hash.wc_head = (ngx_hash_wildcard_t *) hash.hash;
1253
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
331 }
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
332
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
333 if (ctx.keys.dns_wc_tail.nelts) {
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
334
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
335 ngx_qsort(ctx.keys.dns_wc_tail.elts,
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
336 (size_t) ctx.keys.dns_wc_tail.nelts,
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
337 sizeof(ngx_hash_key_t), ngx_http_map_cmp_dns_wildcards);
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
338
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
339 hash.hash = NULL;
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
340 hash.temp_pool = pool;
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
341
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
342 if (ngx_hash_wildcard_init(&hash, ctx.keys.dns_wc_tail.elts,
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
343 ctx.keys.dns_wc_tail.nelts)
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
344 != NGX_OK)
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
345 {
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
346 ngx_destroy_pool(pool);
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
347 return NGX_CONF_ERROR;
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
348 }
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
349
3872
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
350 map->map.hash.wc_tail = (ngx_hash_wildcard_t *) hash.hash;
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
351 }
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
352
3872
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
353 #if (NGX_PCRE)
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
354
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
355 if (ctx.regexes.nelts) {
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
356 map->map.regex = ctx.regexes.elts;
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
357 map->map.nregex = ctx.regexes.nelts;
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
358 }
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
359
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
360 #endif
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
361
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
362 ngx_destroy_pool(pool);
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
363
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
364 return rv;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
365 }
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
366
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
367
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
368 static int ngx_libc_cdecl
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
369 ngx_http_map_cmp_dns_wildcards(const void *one, const void *two)
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
370 {
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
371 ngx_hash_key_t *first, *second;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
372
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
373 first = (ngx_hash_key_t *) one;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
374 second = (ngx_hash_key_t *) two;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
375
3116
98e288c6dac3 If .domain.com, .sub.domain.com, and .domain-some.com were defined,
Igor Sysoev <igor@sysoev.ru>
parents: 2912
diff changeset
376 return ngx_dns_strcmp(first->key.data, second->key.data);
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
377 }
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
378
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
379
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
380 static char *
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
381 ngx_http_map(ngx_conf_t *cf, ngx_command_t *dummy, void *conf)
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
382 {
6535
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
383 u_char *data;
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
384 size_t len;
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
385 ngx_int_t rv;
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
386 ngx_str_t *value, v;
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
387 ngx_uint_t i, key;
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
388 ngx_http_map_conf_ctx_t *ctx;
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
389 ngx_http_complex_value_t cv, *cvp;
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
390 ngx_http_variable_value_t *var, **vp;
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
391 ngx_http_compile_complex_value_t ccv;
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
392
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
393 ctx = cf->ctx;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
394
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
395 value = cf->args->elts;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
396
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
397 if (cf->args->nelts == 1
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
398 && ngx_strcmp(value[0].data, "hostnames") == 0)
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
399 {
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
400 ctx->hostnames = 1;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
401 return NGX_CONF_OK;
6831
014905eb7b3d Map: simplified "map" block parser.
Ruslan Ermilov <ru@nginx.com>
parents: 6535
diff changeset
402 }
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
403
6832
ec10ce307dc0 Map: the "volatile" parameter.
Ruslan Ermilov <ru@nginx.com>
parents: 6831
diff changeset
404 if (cf->args->nelts == 1
ec10ce307dc0 Map: the "volatile" parameter.
Ruslan Ermilov <ru@nginx.com>
parents: 6831
diff changeset
405 && ngx_strcmp(value[0].data, "volatile") == 0)
ec10ce307dc0 Map: the "volatile" parameter.
Ruslan Ermilov <ru@nginx.com>
parents: 6831
diff changeset
406 {
ec10ce307dc0 Map: the "volatile" parameter.
Ruslan Ermilov <ru@nginx.com>
parents: 6831
diff changeset
407 ctx->no_cacheable = 1;
ec10ce307dc0 Map: the "volatile" parameter.
Ruslan Ermilov <ru@nginx.com>
parents: 6831
diff changeset
408 return NGX_CONF_OK;
ec10ce307dc0 Map: the "volatile" parameter.
Ruslan Ermilov <ru@nginx.com>
parents: 6831
diff changeset
409 }
ec10ce307dc0 Map: the "volatile" parameter.
Ruslan Ermilov <ru@nginx.com>
parents: 6831
diff changeset
410
6831
014905eb7b3d Map: simplified "map" block parser.
Ruslan Ermilov <ru@nginx.com>
parents: 6535
diff changeset
411 if (cf->args->nelts != 2) {
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
412 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
413 "invalid number of the map parameters");
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
414 return NGX_CONF_ERROR;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
415 }
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
416
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
417 if (ngx_strcmp(value[0].data, "include") == 0) {
4827
6e46016ea276 Fixed the "include" directive.
Ruslan Ermilov <ru@nginx.com>
parents: 4814
diff changeset
418 return ngx_conf_include(cf, dummy, conf);
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
419 }
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
420
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
421 key = 0;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
422
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
423 for (i = 0; i < value[1].len; i++) {
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
424 key = ngx_hash(key, value[1].data[i]);
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
425 }
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
426
593
425af804d968 nginx-0.3.18-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 591
diff changeset
427 key %= ctx->keys.hsize;
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
428
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
429 vp = ctx->values_hash[key].elts;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
430
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
431 if (vp) {
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
432 for (i = 0; i < ctx->values_hash[key].nelts; i++) {
6535
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
433
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
434 if (vp[i]->valid) {
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
435 data = vp[i]->data;
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
436 len = vp[i]->len;
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
437
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
438 } else {
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
439 cvp = (ngx_http_complex_value_t *) vp[i]->data;
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
440 data = cvp->value.data;
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
441 len = cvp->value.len;
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
442 }
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
443
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
444 if (value[1].len != len) {
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
445 continue;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
446 }
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
447
6535
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
448 if (ngx_strncmp(value[1].data, data, len) == 0) {
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
449 var = vp[i];
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
450 goto found;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
451 }
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
452 }
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
453
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
454 } else {
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
455 if (ngx_array_init(&ctx->values_hash[key], cf->pool, 4,
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
456 sizeof(ngx_http_variable_value_t *))
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
457 != NGX_OK)
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
458 {
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
459 return NGX_CONF_ERROR;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
460 }
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
461 }
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
462
593
425af804d968 nginx-0.3.18-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 591
diff changeset
463 var = ngx_palloc(ctx->keys.pool, sizeof(ngx_http_variable_value_t));
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
464 if (var == NULL) {
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
465 return NGX_CONF_ERROR;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
466 }
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
467
6535
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
468 v.len = value[1].len;
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
469 v.data = ngx_pstrdup(ctx->keys.pool, &value[1]);
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
470 if (v.data == NULL) {
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
471 return NGX_CONF_ERROR;
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
472 }
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
473
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
474 ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t));
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
475
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
476 ccv.cf = ctx->cf;
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
477 ccv.value = &v;
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
478 ccv.complex_value = &cv;
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
479
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
480 if (ngx_http_compile_complex_value(&ccv) != NGX_OK) {
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
481 return NGX_CONF_ERROR;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
482 }
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
483
6535
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
484 if (cv.lengths != NULL) {
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
485 cvp = ngx_palloc(ctx->keys.pool, sizeof(ngx_http_complex_value_t));
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
486 if (cvp == NULL) {
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
487 return NGX_CONF_ERROR;
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
488 }
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
489
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
490 *cvp = cv;
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
491
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
492 var->len = 0;
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
493 var->data = (u_char *) cvp;
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
494 var->valid = 0;
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
495
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
496 } else {
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
497 var->len = v.len;
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
498 var->data = v.data;
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
499 var->valid = 1;
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
500 }
db699978a33f Map: support of complex values in resulting strings.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 6480
diff changeset
501
1565
4c43e25d11ea fix English grammar
Igor Sysoev <igor@sysoev.ru>
parents: 1406
diff changeset
502 var->no_cacheable = 0;
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
503 var->not_found = 0;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
504
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
505 vp = ngx_array_push(&ctx->values_hash[key]);
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
506 if (vp == NULL) {
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
507 return NGX_CONF_ERROR;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
508 }
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
509
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
510 *vp = var;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
511
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
512 found:
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
513
1253
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
514 if (ngx_strcmp(value[0].data, "default") == 0) {
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
515
1253
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
516 if (ctx->default_value) {
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
517 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
1253
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
518 "duplicate default map parameter");
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
519 return NGX_CONF_ERROR;
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
520 }
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
521
1253
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
522 ctx->default_value = var;
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
523
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
524 return NGX_CONF_OK;
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
525 }
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
526
3872
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
527 #if (NGX_PCRE)
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
528
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
529 if (value[0].len && value[0].data[0] == '~') {
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
530 ngx_regex_compile_t rc;
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
531 ngx_http_map_regex_t *regex;
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
532 u_char errstr[NGX_MAX_CONF_ERRSTR];
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
533
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
534 regex = ngx_array_push(&ctx->regexes);
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
535 if (regex == NULL) {
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
536 return NGX_CONF_ERROR;
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
537 }
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
538
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
539 value[0].len--;
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
540 value[0].data++;
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
541
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
542 ngx_memzero(&rc, sizeof(ngx_regex_compile_t));
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
543
3930
ace14fd91086 revert r3875 since now map uses case sensetive regexes by default
Igor Sysoev <igor@sysoev.ru>
parents: 3929
diff changeset
544 if (value[0].data[0] == '*') {
ace14fd91086 revert r3875 since now map uses case sensetive regexes by default
Igor Sysoev <igor@sysoev.ru>
parents: 3929
diff changeset
545 value[0].len--;
ace14fd91086 revert r3875 since now map uses case sensetive regexes by default
Igor Sysoev <igor@sysoev.ru>
parents: 3929
diff changeset
546 value[0].data++;
ace14fd91086 revert r3875 since now map uses case sensetive regexes by default
Igor Sysoev <igor@sysoev.ru>
parents: 3929
diff changeset
547 rc.options = NGX_REGEX_CASELESS;
ace14fd91086 revert r3875 since now map uses case sensetive regexes by default
Igor Sysoev <igor@sysoev.ru>
parents: 3929
diff changeset
548 }
ace14fd91086 revert r3875 since now map uses case sensetive regexes by default
Igor Sysoev <igor@sysoev.ru>
parents: 3929
diff changeset
549
3872
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
550 rc.pattern = value[0];
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
551 rc.err.len = NGX_MAX_CONF_ERRSTR;
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
552 rc.err.data = errstr;
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
553
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
554 regex->regex = ngx_http_regex_compile(ctx->cf, &rc);
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
555 if (regex->regex == NULL) {
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
556 return NGX_CONF_ERROR;
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
557 }
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
558
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
559 regex->value = var;
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
560
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
561 return NGX_CONF_OK;
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
562 }
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
563
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
564 #endif
83cd1910329c allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents: 3792
diff changeset
565
3791
11701c4c0358 use "\" to escape "default", "include", and "hostnames" values instead of "!"
Igor Sysoev <igor@sysoev.ru>
parents: 3790
diff changeset
566 if (value[0].len && value[0].data[0] == '\\') {
1253
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
567 value[0].len--;
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
568 value[0].data++;
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
569 }
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
570
6230
2a621245f4cf Win32: MSVC 2015 compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5362
diff changeset
571 rv = ngx_hash_add_key(&ctx->keys, &value[0], var,
1253
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
572 (ctx->hostnames) ? NGX_HASH_WILDCARD_KEY : 0);
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
573
6230
2a621245f4cf Win32: MSVC 2015 compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5362
diff changeset
574 if (rv == NGX_OK) {
591
8c0cdd81580e nginx-0.3.17-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 589
diff changeset
575 return NGX_CONF_OK;
8c0cdd81580e nginx-0.3.17-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 589
diff changeset
576 }
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
577
6230
2a621245f4cf Win32: MSVC 2015 compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5362
diff changeset
578 if (rv == NGX_DECLINED) {
1253
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
579 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
580 "invalid hostname or wildcard \"%V\"", &value[0]);
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
581 }
8ef04207c84f the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents: 797
diff changeset
582
6230
2a621245f4cf Win32: MSVC 2015 compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5362
diff changeset
583 if (rv == NGX_BUSY) {
591
8c0cdd81580e nginx-0.3.17-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 589
diff changeset
584 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
8c0cdd81580e nginx-0.3.17-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 589
diff changeset
585 "conflicting parameter \"%V\"", &value[0]);
8c0cdd81580e nginx-0.3.17-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 589
diff changeset
586 }
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
587
591
8c0cdd81580e nginx-0.3.17-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 589
diff changeset
588 return NGX_CONF_ERROR;
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
589 }