50
|
1
|
|
2 /*
|
|
3 * Copyright (C) Igor Sysoev
|
|
4 */
|
|
5
|
|
6
|
|
7 #include <ngx_config.h>
|
|
8 #include <ngx_core.h>
|
|
9 #include <ngx_http.h>
|
|
10
|
|
11
|
326
|
12 typedef struct ngx_http_header_val_s ngx_http_header_val_t;
|
|
13
|
|
14 typedef ngx_int_t (*ngx_http_set_header_pt)(ngx_http_request_t *r,
|
|
15 ngx_http_header_val_t *hv, ngx_str_t *value);
|
174
|
16
|
|
17
|
|
18 typedef struct {
|
464
|
19 ngx_str_t name;
|
|
20 ngx_uint_t offset;
|
|
21 ngx_http_set_header_pt handler;
|
326
|
22 } ngx_http_set_header_t;
|
|
23
|
|
24
|
|
25 struct ngx_http_header_val_s {
|
464
|
26 ngx_http_complex_value_t value;
|
|
27 ngx_uint_t hash;
|
|
28 ngx_str_t key;
|
|
29 ngx_http_set_header_pt handler;
|
|
30 ngx_uint_t offset;
|
326
|
31 };
|
|
32
|
|
33
|
376
|
34 #define NGX_HTTP_EXPIRES_OFF 0
|
|
35 #define NGX_HTTP_EXPIRES_EPOCH 1
|
|
36 #define NGX_HTTP_EXPIRES_MAX 2
|
|
37 #define NGX_HTTP_EXPIRES_ACCESS 3
|
|
38 #define NGX_HTTP_EXPIRES_MODIFIED 4
|
394
|
39 #define NGX_HTTP_EXPIRES_DAILY 5
|
376
|
40
|
|
41
|
326
|
42 typedef struct {
|
376
|
43 ngx_uint_t expires;
|
|
44 time_t expires_time;
|
326
|
45 ngx_array_t *headers;
|
50
|
46 } ngx_http_headers_conf_t;
|
|
47
|
|
48
|
326
|
49 static ngx_int_t ngx_http_set_expires(ngx_http_request_t *r,
|
|
50 ngx_http_headers_conf_t *conf);
|
|
51 static ngx_int_t ngx_http_add_cache_control(ngx_http_request_t *r,
|
|
52 ngx_http_header_val_t *hv, ngx_str_t *value);
|
|
53 static ngx_int_t ngx_http_set_last_modified(ngx_http_request_t *r,
|
|
54 ngx_http_header_val_t *hv, ngx_str_t *value);
|
|
55
|
50
|
56 static void *ngx_http_headers_create_conf(ngx_conf_t *cf);
|
|
57 static char *ngx_http_headers_merge_conf(ngx_conf_t *cf,
|
122
|
58 void *parent, void *child);
|
230
|
59 static ngx_int_t ngx_http_headers_filter_init(ngx_conf_t *cf);
|
50
|
60 static char *ngx_http_headers_expires(ngx_conf_t *cf, ngx_command_t *cmd,
|
|
61 void *conf);
|
122
|
62 static char *ngx_http_headers_add(ngx_conf_t *cf, ngx_command_t *cmd,
|
|
63 void *conf);
|
50
|
64
|
|
65
|
326
|
66 static ngx_http_set_header_t ngx_http_set_headers[] = {
|
|
67
|
|
68 { ngx_string("Cache-Control"), 0, ngx_http_add_cache_control },
|
|
69
|
|
70 { ngx_string("Last-Modified"),
|
|
71 offsetof(ngx_http_headers_out_t, last_modified),
|
|
72 ngx_http_set_last_modified },
|
|
73
|
|
74 { ngx_null_string, 0, NULL }
|
|
75 };
|
|
76
|
|
77
|
50
|
78 static ngx_command_t ngx_http_headers_filter_commands[] = {
|
|
79
|
|
80 { ngx_string("expires"),
|
122
|
81 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
|
376
|
82 |NGX_CONF_TAKE12,
|
50
|
83 ngx_http_headers_expires,
|
|
84 NGX_HTTP_LOC_CONF_OFFSET,
|
|
85 0,
|
|
86 NULL},
|
|
87
|
122
|
88 { ngx_string("add_header"),
|
|
89 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
|
|
90 |NGX_CONF_TAKE2,
|
|
91 ngx_http_headers_add,
|
|
92 NGX_HTTP_LOC_CONF_OFFSET,
|
|
93 0,
|
|
94 NULL},
|
|
95
|
50
|
96 ngx_null_command
|
|
97 };
|
|
98
|
|
99
|
|
100 static ngx_http_module_t ngx_http_headers_filter_module_ctx = {
|
58
|
101 NULL, /* preconfiguration */
|
230
|
102 ngx_http_headers_filter_init, /* postconfiguration */
|
50
|
103
|
|
104 NULL, /* create main configuration */
|
|
105 NULL, /* init main configuration */
|
|
106
|
|
107 NULL, /* create server configuration */
|
|
108 NULL, /* merge server configuration */
|
|
109
|
|
110 ngx_http_headers_create_conf, /* create location configuration */
|
|
111 ngx_http_headers_merge_conf /* merge location configuration */
|
|
112 };
|
|
113
|
|
114
|
|
115 ngx_module_t ngx_http_headers_filter_module = {
|
58
|
116 NGX_MODULE_V1,
|
50
|
117 &ngx_http_headers_filter_module_ctx, /* module context */
|
|
118 ngx_http_headers_filter_commands, /* module directives */
|
|
119 NGX_HTTP_MODULE, /* module type */
|
90
|
120 NULL, /* init master */
|
230
|
121 NULL, /* init module */
|
90
|
122 NULL, /* init process */
|
|
123 NULL, /* init thread */
|
|
124 NULL, /* exit thread */
|
|
125 NULL, /* exit process */
|
|
126 NULL, /* exit master */
|
|
127 NGX_MODULE_V1_PADDING
|
50
|
128 };
|
|
129
|
|
130
|
|
131 static ngx_http_output_header_filter_pt ngx_http_next_header_filter;
|
|
132
|
|
133
|
|
134 static ngx_int_t
|
|
135 ngx_http_headers_filter(ngx_http_request_t *r)
|
|
136 {
|
326
|
137 ngx_str_t value;
|
58
|
138 ngx_uint_t i;
|
174
|
139 ngx_http_header_val_t *h;
|
50
|
140 ngx_http_headers_conf_t *conf;
|
|
141
|
326
|
142 conf = ngx_http_get_module_loc_conf(r, ngx_http_headers_filter_module);
|
|
143
|
|
144 if ((conf->expires == NGX_HTTP_EXPIRES_OFF && conf->headers == NULL)
|
|
145 || r != r->main
|
212
|
146 || (r->headers_out.status != NGX_HTTP_OK
|
|
147 && r->headers_out.status != NGX_HTTP_NO_CONTENT
|
650
|
148 && r->headers_out.status != NGX_HTTP_PARTIAL_CONTENT
|
212
|
149 && r->headers_out.status != NGX_HTTP_MOVED_PERMANENTLY
|
|
150 && r->headers_out.status != NGX_HTTP_MOVED_TEMPORARILY
|
|
151 && r->headers_out.status != NGX_HTTP_NOT_MODIFIED))
|
92
|
152 {
|
50
|
153 return ngx_http_next_header_filter(r);
|
|
154 }
|
|
155
|
|
156 if (conf->expires != NGX_HTTP_EXPIRES_OFF) {
|
326
|
157 if (ngx_http_set_expires(r, conf) != NGX_OK) {
|
|
158 return NGX_ERROR;
|
|
159 }
|
|
160 }
|
58
|
161
|
326
|
162 if (conf->headers) {
|
|
163 h = conf->headers->elts;
|
|
164 for (i = 0; i < conf->headers->nelts; i++) {
|
50
|
165
|
464
|
166 if (ngx_http_complex_value(r, &h[i].value, &value) != NGX_OK) {
|
|
167 return NGX_ERROR;
|
58
|
168 }
|
|
169
|
326
|
170 if (h[i].handler(r, &h[i], &value) != NGX_OK) {
|
50
|
171 return NGX_ERROR;
|
|
172 }
|
|
173 }
|
|
174 }
|
|
175
|
326
|
176 return ngx_http_next_header_filter(r);
|
|
177 }
|
|
178
|
122
|
179
|
326
|
180 static ngx_int_t
|
|
181 ngx_http_set_expires(ngx_http_request_t *r, ngx_http_headers_conf_t *conf)
|
|
182 {
|
|
183 size_t len;
|
394
|
184 time_t now, expires_time, max_age;
|
326
|
185 ngx_uint_t i;
|
|
186 ngx_table_elt_t *expires, *cc, **ccp;
|
122
|
187
|
326
|
188 expires = r->headers_out.expires;
|
|
189
|
|
190 if (expires == NULL) {
|
|
191
|
|
192 expires = ngx_list_push(&r->headers_out.headers);
|
|
193 if (expires == NULL) {
|
|
194 return NGX_ERROR;
|
|
195 }
|
122
|
196
|
326
|
197 r->headers_out.expires = expires;
|
|
198
|
|
199 expires->hash = 1;
|
570
|
200 ngx_str_set(&expires->key, "Expires");
|
326
|
201 }
|
|
202
|
|
203 len = sizeof("Mon, 28 Sep 1970 06:00:00 GMT");
|
|
204 expires->value.len = len - 1;
|
|
205
|
|
206 ccp = r->headers_out.cache_control.elts;
|
|
207
|
|
208 if (ccp == NULL) {
|
|
209
|
|
210 if (ngx_array_init(&r->headers_out.cache_control, r->pool,
|
|
211 1, sizeof(ngx_table_elt_t *))
|
|
212 != NGX_OK)
|
|
213 {
|
|
214 return NGX_ERROR;
|
122
|
215 }
|
|
216
|
|
217 ccp = ngx_array_push(&r->headers_out.cache_control);
|
|
218 if (ccp == NULL) {
|
|
219 return NGX_ERROR;
|
|
220 }
|
|
221
|
|
222 cc = ngx_list_push(&r->headers_out.headers);
|
|
223 if (cc == NULL) {
|
|
224 return NGX_ERROR;
|
|
225 }
|
|
226
|
|
227 cc->hash = 1;
|
570
|
228 ngx_str_set(&cc->key, "Cache-Control");
|
122
|
229 *ccp = cc;
|
326
|
230
|
|
231 } else {
|
|
232 for (i = 1; i < r->headers_out.cache_control.nelts; i++) {
|
|
233 ccp[i]->hash = 0;
|
|
234 }
|
|
235
|
|
236 cc = ccp[0];
|
|
237 }
|
|
238
|
|
239 if (conf->expires == NGX_HTTP_EXPIRES_EPOCH) {
|
|
240 expires->value.data = (u_char *) "Thu, 01 Jan 1970 00:00:01 GMT";
|
570
|
241 ngx_str_set(&cc->value, "no-cache");
|
326
|
242 return NGX_OK;
|
|
243 }
|
|
244
|
|
245 if (conf->expires == NGX_HTTP_EXPIRES_MAX) {
|
|
246 expires->value.data = (u_char *) "Thu, 31 Dec 2037 23:55:55 GMT";
|
|
247 /* 10 years */
|
570
|
248 ngx_str_set(&cc->value, "max-age=315360000");
|
326
|
249 return NGX_OK;
|
|
250 }
|
|
251
|
382
|
252 expires->value.data = ngx_pnalloc(r->pool, len);
|
326
|
253 if (expires->value.data == NULL) {
|
|
254 return NGX_ERROR;
|
|
255 }
|
|
256
|
646
|
257 if (conf->expires_time == 0 && conf->expires != NGX_HTTP_EXPIRES_DAILY) {
|
326
|
258 ngx_memcpy(expires->value.data, ngx_cached_http_time.data,
|
|
259 ngx_cached_http_time.len + 1);
|
570
|
260 ngx_str_set(&cc->value, "max-age=0");
|
326
|
261 return NGX_OK;
|
122
|
262 }
|
|
263
|
394
|
264 now = ngx_time();
|
|
265
|
646
|
266 if (conf->expires == NGX_HTTP_EXPIRES_DAILY) {
|
|
267 expires_time = ngx_next_time(conf->expires_time);
|
|
268 max_age = expires_time - now;
|
|
269
|
|
270 } else if (conf->expires == NGX_HTTP_EXPIRES_ACCESS
|
|
271 || r->headers_out.last_modified_time == -1)
|
376
|
272 {
|
394
|
273 expires_time = now + conf->expires_time;
|
|
274 max_age = conf->expires_time;
|
|
275
|
376
|
276 } else {
|
394
|
277 expires_time = r->headers_out.last_modified_time + conf->expires_time;
|
|
278 max_age = expires_time - now;
|
376
|
279 }
|
|
280
|
394
|
281 ngx_http_time(expires->value.data, expires_time);
|
376
|
282
|
560
|
283 if (conf->expires_time < 0 || max_age < 0) {
|
570
|
284 ngx_str_set(&cc->value, "no-cache");
|
326
|
285 return NGX_OK;
|
|
286 }
|
122
|
287
|
382
|
288 cc->value.data = ngx_pnalloc(r->pool,
|
|
289 sizeof("max-age=") + NGX_TIME_T_LEN + 1);
|
326
|
290 if (cc->value.data == NULL) {
|
|
291 return NGX_ERROR;
|
|
292 }
|
|
293
|
394
|
294 cc->value.len = ngx_sprintf(cc->value.data, "max-age=%T", max_age)
|
326
|
295 - cc->value.data;
|
|
296
|
|
297 return NGX_OK;
|
|
298 }
|
|
299
|
|
300
|
|
301 static ngx_int_t
|
|
302 ngx_http_add_header(ngx_http_request_t *r, ngx_http_header_val_t *hv,
|
|
303 ngx_str_t *value)
|
|
304 {
|
|
305 ngx_table_elt_t *h;
|
174
|
306
|
430
|
307 if (value->len) {
|
|
308 h = ngx_list_push(&r->headers_out.headers);
|
|
309 if (h == NULL) {
|
|
310 return NGX_ERROR;
|
|
311 }
|
|
312
|
464
|
313 h->hash = hv->hash;
|
|
314 h->key = hv->key;
|
430
|
315 h->value = *value;
|
326
|
316 }
|
|
317
|
|
318 return NGX_OK;
|
|
319 }
|
|
320
|
174
|
321
|
326
|
322 static ngx_int_t
|
|
323 ngx_http_add_cache_control(ngx_http_request_t *r, ngx_http_header_val_t *hv,
|
|
324 ngx_str_t *value)
|
|
325 {
|
|
326 ngx_table_elt_t *cc, **ccp;
|
|
327
|
|
328 ccp = r->headers_out.cache_control.elts;
|
|
329
|
|
330 if (ccp == NULL) {
|
|
331
|
|
332 if (ngx_array_init(&r->headers_out.cache_control, r->pool,
|
|
333 1, sizeof(ngx_table_elt_t *))
|
|
334 != NGX_OK)
|
|
335 {
|
|
336 return NGX_ERROR;
|
122
|
337 }
|
|
338 }
|
|
339
|
326
|
340 ccp = ngx_array_push(&r->headers_out.cache_control);
|
|
341 if (ccp == NULL) {
|
|
342 return NGX_ERROR;
|
|
343 }
|
|
344
|
|
345 cc = ngx_list_push(&r->headers_out.headers);
|
|
346 if (cc == NULL) {
|
|
347 return NGX_ERROR;
|
|
348 }
|
|
349
|
|
350 cc->hash = 1;
|
570
|
351 ngx_str_set(&cc->key, "Cache-Control");
|
326
|
352 cc->value = *value;
|
|
353
|
|
354 *ccp = cc;
|
|
355
|
|
356 return NGX_OK;
|
|
357 }
|
|
358
|
|
359
|
|
360 static ngx_int_t
|
|
361 ngx_http_set_last_modified(ngx_http_request_t *r, ngx_http_header_val_t *hv,
|
|
362 ngx_str_t *value)
|
|
363 {
|
|
364 ngx_table_elt_t *h, **old;
|
|
365
|
|
366 if (hv->offset) {
|
|
367 old = (ngx_table_elt_t **) ((char *) &r->headers_out + hv->offset);
|
|
368
|
|
369 } else {
|
|
370 old = NULL;
|
|
371 }
|
|
372
|
348
|
373 r->headers_out.last_modified_time = -1;
|
|
374
|
326
|
375 if (old == NULL || *old == NULL) {
|
348
|
376
|
|
377 if (value->len == 0) {
|
|
378 return NGX_OK;
|
|
379 }
|
|
380
|
326
|
381 h = ngx_list_push(&r->headers_out.headers);
|
|
382 if (h == NULL) {
|
|
383 return NGX_ERROR;
|
|
384 }
|
|
385
|
|
386 } else {
|
|
387 h = *old;
|
348
|
388
|
|
389 if (value->len == 0) {
|
|
390 h->hash = 0;
|
|
391 return NGX_OK;
|
|
392 }
|
326
|
393 }
|
|
394
|
464
|
395 h->hash = hv->hash;
|
|
396 h->key = hv->key;
|
326
|
397 h->value = *value;
|
|
398
|
|
399 return NGX_OK;
|
50
|
400 }
|
|
401
|
|
402
|
|
403 static void *
|
|
404 ngx_http_headers_create_conf(ngx_conf_t *cf)
|
126
|
405 {
|
50
|
406 ngx_http_headers_conf_t *conf;
|
|
407
|
122
|
408 conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_headers_conf_t));
|
50
|
409 if (conf == NULL) {
|
496
|
410 return NULL;
|
50
|
411 }
|
|
412
|
122
|
413 /*
|
|
414 * set by ngx_pcalloc():
|
|
415 *
|
|
416 * conf->headers = NULL;
|
376
|
417 * conf->expires_time = 0;
|
122
|
418 */
|
|
419
|
376
|
420 conf->expires = NGX_CONF_UNSET_UINT;
|
50
|
421
|
|
422 return conf;
|
|
423 }
|
|
424
|
|
425
|
|
426 static char *
|
|
427 ngx_http_headers_merge_conf(ngx_conf_t *cf, void *parent, void *child)
|
|
428 {
|
|
429 ngx_http_headers_conf_t *prev = parent;
|
|
430 ngx_http_headers_conf_t *conf = child;
|
|
431
|
376
|
432 if (conf->expires == NGX_CONF_UNSET_UINT) {
|
|
433 conf->expires = prev->expires;
|
|
434 conf->expires_time = prev->expires_time;
|
|
435
|
|
436 if (conf->expires == NGX_CONF_UNSET_UINT) {
|
|
437 conf->expires = NGX_HTTP_EXPIRES_OFF;
|
|
438 }
|
122
|
439 }
|
|
440
|
|
441 if (conf->headers == NULL) {
|
|
442 conf->headers = prev->headers;
|
|
443 }
|
|
444
|
50
|
445 return NGX_CONF_OK;
|
|
446 }
|
|
447
|
|
448
|
230
|
449 static ngx_int_t
|
|
450 ngx_http_headers_filter_init(ngx_conf_t *cf)
|
|
451 {
|
|
452 ngx_http_next_header_filter = ngx_http_top_header_filter;
|
|
453 ngx_http_top_header_filter = ngx_http_headers_filter;
|
|
454
|
|
455 return NGX_OK;
|
|
456 }
|
|
457
|
|
458
|
50
|
459 static char *
|
|
460 ngx_http_headers_expires(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|
461 {
|
|
462 ngx_http_headers_conf_t *hcf = conf;
|
|
463
|
376
|
464 ngx_uint_t minus, n;
|
50
|
465 ngx_str_t *value;
|
|
466
|
376
|
467 if (hcf->expires != NGX_CONF_UNSET_UINT) {
|
50
|
468 return "is duplicate";
|
|
469 }
|
|
470
|
|
471 value = cf->args->elts;
|
|
472
|
376
|
473 if (cf->args->nelts == 2) {
|
|
474
|
|
475 if (ngx_strcmp(value[1].data, "epoch") == 0) {
|
|
476 hcf->expires = NGX_HTTP_EXPIRES_EPOCH;
|
|
477 return NGX_CONF_OK;
|
|
478 }
|
|
479
|
|
480 if (ngx_strcmp(value[1].data, "max") == 0) {
|
|
481 hcf->expires = NGX_HTTP_EXPIRES_MAX;
|
|
482 return NGX_CONF_OK;
|
|
483 }
|
50
|
484
|
376
|
485 if (ngx_strcmp(value[1].data, "off") == 0) {
|
|
486 hcf->expires = NGX_HTTP_EXPIRES_OFF;
|
|
487 return NGX_CONF_OK;
|
|
488 }
|
|
489
|
|
490 hcf->expires = NGX_HTTP_EXPIRES_ACCESS;
|
|
491
|
|
492 n = 1;
|
|
493
|
|
494 } else { /* cf->args->nelts == 3 */
|
|
495
|
|
496 if (ngx_strcmp(value[1].data, "modified") != 0) {
|
|
497 return "invalid value";
|
|
498 }
|
|
499
|
|
500 hcf->expires = NGX_HTTP_EXPIRES_MODIFIED;
|
|
501
|
|
502 n = 2;
|
238
|
503 }
|
|
504
|
394
|
505 if (value[n].data[0] == '@') {
|
|
506 value[n].data++;
|
|
507 value[n].len--;
|
|
508 minus = 0;
|
|
509
|
|
510 if (hcf->expires == NGX_HTTP_EXPIRES_MODIFIED) {
|
640
|
511 return "daily time cannot be used with \"modified\" parameter";
|
394
|
512 }
|
|
513
|
|
514 hcf->expires = NGX_HTTP_EXPIRES_DAILY;
|
|
515
|
|
516 } else if (value[n].data[0] == '+') {
|
376
|
517 value[n].data++;
|
|
518 value[n].len--;
|
50
|
519 minus = 0;
|
|
520
|
376
|
521 } else if (value[n].data[0] == '-') {
|
|
522 value[n].data++;
|
|
523 value[n].len--;
|
50
|
524 minus = 1;
|
|
525
|
|
526 } else {
|
|
527 minus = 0;
|
|
528 }
|
|
529
|
376
|
530 hcf->expires_time = ngx_parse_time(&value[n], 1);
|
50
|
531
|
376
|
532 if (hcf->expires_time == NGX_ERROR) {
|
50
|
533 return "invalid value";
|
|
534 }
|
126
|
535
|
394
|
536 if (hcf->expires == NGX_HTTP_EXPIRES_DAILY
|
|
537 && hcf->expires_time > 24 * 60 * 60)
|
|
538 {
|
|
539 return "daily time value must be less than 24 hours";
|
|
540 }
|
|
541
|
376
|
542 if (hcf->expires_time == NGX_PARSE_LARGE_TIME) {
|
50
|
543 return "value must be less than 68 years";
|
|
544 }
|
|
545
|
|
546 if (minus) {
|
376
|
547 hcf->expires_time = - hcf->expires_time;
|
50
|
548 }
|
|
549
|
|
550 return NGX_CONF_OK;
|
|
551 }
|
122
|
552
|
|
553
|
|
554 static char *
|
|
555 ngx_http_headers_add(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|
556 {
|
|
557 ngx_http_headers_conf_t *hcf = conf;
|
|
558
|
464
|
559 ngx_str_t *value;
|
|
560 ngx_uint_t i;
|
|
561 ngx_http_header_val_t *hv;
|
|
562 ngx_http_set_header_t *set;
|
|
563 ngx_http_compile_complex_value_t ccv;
|
122
|
564
|
|
565 value = cf->args->elts;
|
|
566
|
|
567 if (hcf->headers == NULL) {
|
174
|
568 hcf->headers = ngx_array_create(cf->pool, 1,
|
|
569 sizeof(ngx_http_header_val_t));
|
122
|
570 if (hcf->headers == NULL) {
|
|
571 return NGX_CONF_ERROR;
|
|
572 }
|
|
573 }
|
|
574
|
464
|
575 hv = ngx_array_push(hcf->headers);
|
|
576 if (hv == NULL) {
|
122
|
577 return NGX_CONF_ERROR;
|
|
578 }
|
|
579
|
464
|
580 hv->hash = 1;
|
|
581 hv->key = value[1];
|
|
582 hv->handler = ngx_http_add_header;
|
|
583 hv->offset = 0;
|
174
|
584
|
464
|
585 set = ngx_http_set_headers;
|
|
586 for (i = 0; set[i].name.len; i++) {
|
|
587 if (ngx_strcasecmp(value[1].data, set[i].name.data) != 0) {
|
326
|
588 continue;
|
|
589 }
|
|
590
|
464
|
591 hv->offset = set[i].offset;
|
|
592 hv->handler = set[i].handler;
|
|
593
|
326
|
594 break;
|
|
595 }
|
|
596
|
466
|
597 if (value[2].len == 0) {
|
|
598 ngx_memzero(&hv->value, sizeof(ngx_http_complex_value_t));
|
|
599 return NGX_CONF_OK;
|
|
600 }
|
|
601
|
464
|
602 ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t));
|
174
|
603
|
464
|
604 ccv.cf = cf;
|
|
605 ccv.value = &value[2];
|
|
606 ccv.complex_value = &hv->value;
|
174
|
607
|
464
|
608 if (ngx_http_compile_complex_value(&ccv) != NGX_OK) {
|
174
|
609 return NGX_CONF_ERROR;
|
|
610 }
|
122
|
611
|
|
612 return NGX_CONF_OK;
|
|
613 }
|