Mercurial > hg > nginx
annotate src/http/ngx_http_script.c @ 7459:982008fbc4ba
SSL: removed logging of empty "(SSL:)" in ngx_ssl_error().
The "(SSL:)" snippet currently appears in logs when nginx code uses
ngx_ssl_error() to log an error, but OpenSSL's error queue is empty.
This can happen either because the error wasn't in fact from OpenSSL,
or because OpenSSL did not indicate the error in the error queue
for some reason.
In particular, currently "(SSL:)" can be seen in errors at least in
the following cases:
- When SSL_write() fails due to a syscall error,
"[info] ... SSL_write() failed (SSL:) (32: Broken pipe)...".
- When loading a certificate with no data in it,
"[emerg] PEM_read_bio_X509_AUX(...) failed (SSL:)".
This can easily happen due to an additional empty line before
the end line, so all lines of the certificate are interpreted
as header lines.
- When trying to configure an unknown curve,
"[emerg] SSL_CTX_set1_curves_list("foo") failed (SSL:)".
Likely there are other cases as well.
With this change, "(SSL:...)" will be only added to the error message
if there is something in the error queue. This is expected to make
logs more readable in the above cases. Additionally, with this change
it is now possible to use ngx_ssl_error() to log errors when some
of the possible errors are not from OpenSSL and not expected to have
anything in the error queue.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 25 Feb 2019 16:41:15 +0300 |
parents | 5efc23d83bc2 |
children | b82162b8496a |
rev | line source |
---|---|
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
99
diff
changeset
|
1 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
99
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
4412 | 4 * Copyright (C) Nginx, Inc. |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
99
diff
changeset
|
5 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
99
diff
changeset
|
6 |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_config.h> |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 #include <ngx_core.h> |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 #include <ngx_http.h> |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
12 |
2577
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
13 static ngx_int_t ngx_http_script_init_arrays(ngx_http_script_compile_t *sc); |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
14 static ngx_int_t ngx_http_script_done(ngx_http_script_compile_t *sc); |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
15 static ngx_int_t ngx_http_script_add_copy_code(ngx_http_script_compile_t *sc, |
2587
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
16 ngx_str_t *value, ngx_uint_t last); |
2577
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
17 static ngx_int_t ngx_http_script_add_var_code(ngx_http_script_compile_t *sc, |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
18 ngx_str_t *name); |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
19 static ngx_int_t ngx_http_script_add_args_code(ngx_http_script_compile_t *sc); |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
20 #if (NGX_PCRE) |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
21 static ngx_int_t ngx_http_script_add_capture_code(ngx_http_script_compile_t *sc, |
6474 | 22 ngx_uint_t n); |
2577
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
23 #endif |
2587
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
24 static ngx_int_t |
6474 | 25 ngx_http_script_add_full_name_code(ngx_http_script_compile_t *sc); |
2587
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
26 static size_t ngx_http_script_full_name_len_code(ngx_http_script_engine_t *e); |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
27 static void ngx_http_script_full_name_code(ngx_http_script_engine_t *e); |
2577
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
28 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
29 |
509 | 30 #define ngx_http_script_exit (u_char *) &ngx_http_script_exit_code |
31 | |
32 static uintptr_t ngx_http_script_exit_code = (uintptr_t) NULL; | |
33 | |
34 | |
2587
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
35 void |
2609
ad99a49cd313
rename ngx_http_scrip_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2608
diff
changeset
|
36 ngx_http_script_flush_complex_value(ngx_http_request_t *r, |
2587
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
37 ngx_http_complex_value_t *val) |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
38 { |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
39 ngx_uint_t *index; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
40 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
41 index = val->flushes; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
42 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
43 if (index) { |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
44 while (*index != (ngx_uint_t) -1) { |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
45 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
46 if (r->variables[*index].no_cacheable) { |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
47 r->variables[*index].valid = 0; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
48 r->variables[*index].not_found = 0; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
49 } |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
50 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
51 index++; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
52 } |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
53 } |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
54 } |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
55 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
56 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
57 ngx_int_t |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
58 ngx_http_complex_value(ngx_http_request_t *r, ngx_http_complex_value_t *val, |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
59 ngx_str_t *value) |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
60 { |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
61 size_t len; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
62 ngx_http_script_code_pt code; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
63 ngx_http_script_len_code_pt lcode; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
64 ngx_http_script_engine_t e; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
65 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
66 if (val->lengths == NULL) { |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
67 *value = val->value; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
68 return NGX_OK; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
69 } |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
70 |
2609
ad99a49cd313
rename ngx_http_scrip_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2608
diff
changeset
|
71 ngx_http_script_flush_complex_value(r, val); |
2587
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
72 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
73 ngx_memzero(&e, sizeof(ngx_http_script_engine_t)); |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
74 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
75 e.ip = val->lengths; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
76 e.request = r; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
77 e.flushed = 1; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
78 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
79 len = 0; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
80 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
81 while (*(uintptr_t *) e.ip) { |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
82 lcode = *(ngx_http_script_len_code_pt *) e.ip; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
83 len += lcode(&e); |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
84 } |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
85 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
86 value->len = len; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
87 value->data = ngx_pnalloc(r->pool, len); |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
88 if (value->data == NULL) { |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
89 return NGX_ERROR; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
90 } |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
91 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
92 e.ip = val->values; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
93 e.pos = value->data; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
94 e.buf = *value; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
95 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
96 while (*(uintptr_t *) e.ip) { |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
97 code = *(ngx_http_script_code_pt *) e.ip; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
98 code((ngx_http_script_engine_t *) &e); |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
99 } |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
100 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
101 *value = e.buf; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
102 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
103 return NGX_OK; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
104 } |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
105 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
106 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
107 ngx_int_t |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
108 ngx_http_compile_complex_value(ngx_http_compile_complex_value_t *ccv) |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
109 { |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
110 ngx_str_t *v; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
111 ngx_uint_t i, n, nv, nc; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
112 ngx_array_t flushes, lengths, values, *pf, *pl, *pv; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
113 ngx_http_script_compile_t sc; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
114 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
115 v = ccv->value; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
116 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
117 nv = 0; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
118 nc = 0; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
119 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
120 for (i = 0; i < v->len; i++) { |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
121 if (v->data[i] == '$') { |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
122 if (v->data[i + 1] >= '1' && v->data[i + 1] <= '9') { |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
123 nc++; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
124 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
125 } else { |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
126 nv++; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
127 } |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
128 } |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
129 } |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
130 |
4947
4251e72b8bb4
Allow the complex value to be defined as an empty string.
Ruslan Ermilov <ru@nginx.com>
parents:
4617
diff
changeset
|
131 if ((v->len == 0 || v->data[0] != '$') |
4251e72b8bb4
Allow the complex value to be defined as an empty string.
Ruslan Ermilov <ru@nginx.com>
parents:
4617
diff
changeset
|
132 && (ccv->conf_prefix || ccv->root_prefix)) |
4251e72b8bb4
Allow the complex value to be defined as an empty string.
Ruslan Ermilov <ru@nginx.com>
parents:
4617
diff
changeset
|
133 { |
5330
314c3d7cc3a5
Backed out f1a91825730a and 7094bd12c1ff.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5317
diff
changeset
|
134 if (ngx_conf_full_name(ccv->cf->cycle, v, ccv->conf_prefix) != NGX_OK) { |
2587
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
135 return NGX_ERROR; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
136 } |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
137 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
138 ccv->conf_prefix = 0; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
139 ccv->root_prefix = 0; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
140 } |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
141 |
2608
2f4a3a4dfd34
fix plain text values using relative path in ngx_http_complex_value(),
Igor Sysoev <igor@sysoev.ru>
parents:
2587
diff
changeset
|
142 ccv->complex_value->value = *v; |
2f4a3a4dfd34
fix plain text values using relative path in ngx_http_complex_value(),
Igor Sysoev <igor@sysoev.ru>
parents:
2587
diff
changeset
|
143 ccv->complex_value->flushes = NULL; |
2f4a3a4dfd34
fix plain text values using relative path in ngx_http_complex_value(),
Igor Sysoev <igor@sysoev.ru>
parents:
2587
diff
changeset
|
144 ccv->complex_value->lengths = NULL; |
2f4a3a4dfd34
fix plain text values using relative path in ngx_http_complex_value(),
Igor Sysoev <igor@sysoev.ru>
parents:
2587
diff
changeset
|
145 ccv->complex_value->values = NULL; |
2f4a3a4dfd34
fix plain text values using relative path in ngx_http_complex_value(),
Igor Sysoev <igor@sysoev.ru>
parents:
2587
diff
changeset
|
146 |
2587
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
147 if (nv == 0 && nc == 0) { |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
148 return NGX_OK; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
149 } |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
150 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
151 n = nv + 1; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
152 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
153 if (ngx_array_init(&flushes, ccv->cf->pool, n, sizeof(ngx_uint_t)) |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
154 != NGX_OK) |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
155 { |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
156 return NGX_ERROR; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
157 } |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
158 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
159 n = nv * (2 * sizeof(ngx_http_script_copy_code_t) |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
160 + sizeof(ngx_http_script_var_code_t)) |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
161 + sizeof(uintptr_t); |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
162 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
163 if (ngx_array_init(&lengths, ccv->cf->pool, n, 1) != NGX_OK) { |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
164 return NGX_ERROR; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
165 } |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
166 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
167 n = (nv * (2 * sizeof(ngx_http_script_copy_code_t) |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
168 + sizeof(ngx_http_script_var_code_t)) |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
169 + sizeof(uintptr_t) |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
170 + v->len |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
171 + sizeof(uintptr_t) - 1) |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
172 & ~(sizeof(uintptr_t) - 1); |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
173 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
174 if (ngx_array_init(&values, ccv->cf->pool, n, 1) != NGX_OK) { |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
175 return NGX_ERROR; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
176 } |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
177 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
178 pf = &flushes; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
179 pl = &lengths; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
180 pv = &values; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
181 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
182 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t)); |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
183 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
184 sc.cf = ccv->cf; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
185 sc.source = v; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
186 sc.flushes = &pf; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
187 sc.lengths = &pl; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
188 sc.values = &pv; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
189 sc.complete_lengths = 1; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
190 sc.complete_values = 1; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
191 sc.zero = ccv->zero; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
192 sc.conf_prefix = ccv->conf_prefix; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
193 sc.root_prefix = ccv->root_prefix; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
194 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
195 if (ngx_http_script_compile(&sc) != NGX_OK) { |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
196 return NGX_ERROR; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
197 } |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
198 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
199 if (flushes.nelts) { |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
200 ccv->complex_value->flushes = flushes.elts; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
201 ccv->complex_value->flushes[flushes.nelts] = (ngx_uint_t) -1; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
202 } |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
203 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
204 ccv->complex_value->lengths = lengths.elts; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
205 ccv->complex_value->values = values.elts; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
206 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
207 return NGX_OK; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
208 } |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
209 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
210 |
3756
7224d008faaf
new ngx_http_secure_link_module with secure_link, secure_link_md5, and
Igor Sysoev <igor@sysoev.ru>
parents:
3691
diff
changeset
|
211 char * |
3761 | 212 ngx_http_set_complex_value_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
3756
7224d008faaf
new ngx_http_secure_link_module with secure_link, secure_link_md5, and
Igor Sysoev <igor@sysoev.ru>
parents:
3691
diff
changeset
|
213 { |
7224d008faaf
new ngx_http_secure_link_module with secure_link, secure_link_md5, and
Igor Sysoev <igor@sysoev.ru>
parents:
3691
diff
changeset
|
214 char *p = conf; |
7224d008faaf
new ngx_http_secure_link_module with secure_link, secure_link_md5, and
Igor Sysoev <igor@sysoev.ru>
parents:
3691
diff
changeset
|
215 |
7224d008faaf
new ngx_http_secure_link_module with secure_link, secure_link_md5, and
Igor Sysoev <igor@sysoev.ru>
parents:
3691
diff
changeset
|
216 ngx_str_t *value; |
7224d008faaf
new ngx_http_secure_link_module with secure_link, secure_link_md5, and
Igor Sysoev <igor@sysoev.ru>
parents:
3691
diff
changeset
|
217 ngx_http_complex_value_t **cv; |
7224d008faaf
new ngx_http_secure_link_module with secure_link, secure_link_md5, and
Igor Sysoev <igor@sysoev.ru>
parents:
3691
diff
changeset
|
218 ngx_http_compile_complex_value_t ccv; |
7224d008faaf
new ngx_http_secure_link_module with secure_link, secure_link_md5, and
Igor Sysoev <igor@sysoev.ru>
parents:
3691
diff
changeset
|
219 |
7224d008faaf
new ngx_http_secure_link_module with secure_link, secure_link_md5, and
Igor Sysoev <igor@sysoev.ru>
parents:
3691
diff
changeset
|
220 cv = (ngx_http_complex_value_t **) (p + cmd->offset); |
7224d008faaf
new ngx_http_secure_link_module with secure_link, secure_link_md5, and
Igor Sysoev <igor@sysoev.ru>
parents:
3691
diff
changeset
|
221 |
7224d008faaf
new ngx_http_secure_link_module with secure_link, secure_link_md5, and
Igor Sysoev <igor@sysoev.ru>
parents:
3691
diff
changeset
|
222 if (*cv != NULL) { |
6940
39ff6939266e
Unified error messages about duplicate directives.
Ruslan Ermilov <ru@nginx.com>
parents:
6861
diff
changeset
|
223 return "is duplicate"; |
3756
7224d008faaf
new ngx_http_secure_link_module with secure_link, secure_link_md5, and
Igor Sysoev <igor@sysoev.ru>
parents:
3691
diff
changeset
|
224 } |
7224d008faaf
new ngx_http_secure_link_module with secure_link, secure_link_md5, and
Igor Sysoev <igor@sysoev.ru>
parents:
3691
diff
changeset
|
225 |
7224d008faaf
new ngx_http_secure_link_module with secure_link, secure_link_md5, and
Igor Sysoev <igor@sysoev.ru>
parents:
3691
diff
changeset
|
226 *cv = ngx_palloc(cf->pool, sizeof(ngx_http_complex_value_t)); |
7224d008faaf
new ngx_http_secure_link_module with secure_link, secure_link_md5, and
Igor Sysoev <igor@sysoev.ru>
parents:
3691
diff
changeset
|
227 if (*cv == NULL) { |
7224d008faaf
new ngx_http_secure_link_module with secure_link, secure_link_md5, and
Igor Sysoev <igor@sysoev.ru>
parents:
3691
diff
changeset
|
228 return NGX_CONF_ERROR; |
7224d008faaf
new ngx_http_secure_link_module with secure_link, secure_link_md5, and
Igor Sysoev <igor@sysoev.ru>
parents:
3691
diff
changeset
|
229 } |
7224d008faaf
new ngx_http_secure_link_module with secure_link, secure_link_md5, and
Igor Sysoev <igor@sysoev.ru>
parents:
3691
diff
changeset
|
230 |
7224d008faaf
new ngx_http_secure_link_module with secure_link, secure_link_md5, and
Igor Sysoev <igor@sysoev.ru>
parents:
3691
diff
changeset
|
231 value = cf->args->elts; |
7224d008faaf
new ngx_http_secure_link_module with secure_link, secure_link_md5, and
Igor Sysoev <igor@sysoev.ru>
parents:
3691
diff
changeset
|
232 |
7224d008faaf
new ngx_http_secure_link_module with secure_link, secure_link_md5, and
Igor Sysoev <igor@sysoev.ru>
parents:
3691
diff
changeset
|
233 ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); |
7224d008faaf
new ngx_http_secure_link_module with secure_link, secure_link_md5, and
Igor Sysoev <igor@sysoev.ru>
parents:
3691
diff
changeset
|
234 |
7224d008faaf
new ngx_http_secure_link_module with secure_link, secure_link_md5, and
Igor Sysoev <igor@sysoev.ru>
parents:
3691
diff
changeset
|
235 ccv.cf = cf; |
7224d008faaf
new ngx_http_secure_link_module with secure_link, secure_link_md5, and
Igor Sysoev <igor@sysoev.ru>
parents:
3691
diff
changeset
|
236 ccv.value = &value[1]; |
7224d008faaf
new ngx_http_secure_link_module with secure_link, secure_link_md5, and
Igor Sysoev <igor@sysoev.ru>
parents:
3691
diff
changeset
|
237 ccv.complex_value = *cv; |
7224d008faaf
new ngx_http_secure_link_module with secure_link, secure_link_md5, and
Igor Sysoev <igor@sysoev.ru>
parents:
3691
diff
changeset
|
238 |
7224d008faaf
new ngx_http_secure_link_module with secure_link, secure_link_md5, and
Igor Sysoev <igor@sysoev.ru>
parents:
3691
diff
changeset
|
239 if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { |
7224d008faaf
new ngx_http_secure_link_module with secure_link, secure_link_md5, and
Igor Sysoev <igor@sysoev.ru>
parents:
3691
diff
changeset
|
240 return NGX_CONF_ERROR; |
7224d008faaf
new ngx_http_secure_link_module with secure_link, secure_link_md5, and
Igor Sysoev <igor@sysoev.ru>
parents:
3691
diff
changeset
|
241 } |
7224d008faaf
new ngx_http_secure_link_module with secure_link, secure_link_md5, and
Igor Sysoev <igor@sysoev.ru>
parents:
3691
diff
changeset
|
242 |
7224d008faaf
new ngx_http_secure_link_module with secure_link, secure_link_md5, and
Igor Sysoev <igor@sysoev.ru>
parents:
3691
diff
changeset
|
243 return NGX_CONF_OK; |
7224d008faaf
new ngx_http_secure_link_module with secure_link, secure_link_md5, and
Igor Sysoev <igor@sysoev.ru>
parents:
3691
diff
changeset
|
244 } |
7224d008faaf
new ngx_http_secure_link_module with secure_link, secure_link_md5, and
Igor Sysoev <igor@sysoev.ru>
parents:
3691
diff
changeset
|
245 |
7224d008faaf
new ngx_http_secure_link_module with secure_link, secure_link_md5, and
Igor Sysoev <igor@sysoev.ru>
parents:
3691
diff
changeset
|
246 |
3691
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
247 ngx_int_t |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
248 ngx_http_test_predicates(ngx_http_request_t *r, ngx_array_t *predicates) |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
249 { |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
250 ngx_str_t val; |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
251 ngx_uint_t i; |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
252 ngx_http_complex_value_t *cv; |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
253 |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
254 if (predicates == NULL) { |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
255 return NGX_OK; |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
256 } |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
257 |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
258 cv = predicates->elts; |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
259 |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
260 for (i = 0; i < predicates->nelts; i++) { |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
261 if (ngx_http_complex_value(r, &cv[i], &val) != NGX_OK) { |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
262 return NGX_ERROR; |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
263 } |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
264 |
3893
5581586480e9
values starting with '0' were incorrectly assumed to be false
Igor Sysoev <igor@sysoev.ru>
parents:
3887
diff
changeset
|
265 if (val.len && (val.len != 1 || val.data[0] != '0')) { |
3691
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
266 return NGX_DECLINED; |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
267 } |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
268 } |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
269 |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
270 return NGX_OK; |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
271 } |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
272 |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
273 |
7439
5efc23d83bc2
Added the ngx_http_test_required_predicates() function.
Vladimir Homutov <vl@nginx.com>
parents:
7271
diff
changeset
|
274 ngx_int_t |
5efc23d83bc2
Added the ngx_http_test_required_predicates() function.
Vladimir Homutov <vl@nginx.com>
parents:
7271
diff
changeset
|
275 ngx_http_test_required_predicates(ngx_http_request_t *r, |
5efc23d83bc2
Added the ngx_http_test_required_predicates() function.
Vladimir Homutov <vl@nginx.com>
parents:
7271
diff
changeset
|
276 ngx_array_t *predicates) |
5efc23d83bc2
Added the ngx_http_test_required_predicates() function.
Vladimir Homutov <vl@nginx.com>
parents:
7271
diff
changeset
|
277 { |
5efc23d83bc2
Added the ngx_http_test_required_predicates() function.
Vladimir Homutov <vl@nginx.com>
parents:
7271
diff
changeset
|
278 ngx_str_t val; |
5efc23d83bc2
Added the ngx_http_test_required_predicates() function.
Vladimir Homutov <vl@nginx.com>
parents:
7271
diff
changeset
|
279 ngx_uint_t i; |
5efc23d83bc2
Added the ngx_http_test_required_predicates() function.
Vladimir Homutov <vl@nginx.com>
parents:
7271
diff
changeset
|
280 ngx_http_complex_value_t *cv; |
5efc23d83bc2
Added the ngx_http_test_required_predicates() function.
Vladimir Homutov <vl@nginx.com>
parents:
7271
diff
changeset
|
281 |
5efc23d83bc2
Added the ngx_http_test_required_predicates() function.
Vladimir Homutov <vl@nginx.com>
parents:
7271
diff
changeset
|
282 if (predicates == NULL) { |
5efc23d83bc2
Added the ngx_http_test_required_predicates() function.
Vladimir Homutov <vl@nginx.com>
parents:
7271
diff
changeset
|
283 return NGX_OK; |
5efc23d83bc2
Added the ngx_http_test_required_predicates() function.
Vladimir Homutov <vl@nginx.com>
parents:
7271
diff
changeset
|
284 } |
5efc23d83bc2
Added the ngx_http_test_required_predicates() function.
Vladimir Homutov <vl@nginx.com>
parents:
7271
diff
changeset
|
285 |
5efc23d83bc2
Added the ngx_http_test_required_predicates() function.
Vladimir Homutov <vl@nginx.com>
parents:
7271
diff
changeset
|
286 cv = predicates->elts; |
5efc23d83bc2
Added the ngx_http_test_required_predicates() function.
Vladimir Homutov <vl@nginx.com>
parents:
7271
diff
changeset
|
287 |
5efc23d83bc2
Added the ngx_http_test_required_predicates() function.
Vladimir Homutov <vl@nginx.com>
parents:
7271
diff
changeset
|
288 for (i = 0; i < predicates->nelts; i++) { |
5efc23d83bc2
Added the ngx_http_test_required_predicates() function.
Vladimir Homutov <vl@nginx.com>
parents:
7271
diff
changeset
|
289 if (ngx_http_complex_value(r, &cv[i], &val) != NGX_OK) { |
5efc23d83bc2
Added the ngx_http_test_required_predicates() function.
Vladimir Homutov <vl@nginx.com>
parents:
7271
diff
changeset
|
290 return NGX_ERROR; |
5efc23d83bc2
Added the ngx_http_test_required_predicates() function.
Vladimir Homutov <vl@nginx.com>
parents:
7271
diff
changeset
|
291 } |
5efc23d83bc2
Added the ngx_http_test_required_predicates() function.
Vladimir Homutov <vl@nginx.com>
parents:
7271
diff
changeset
|
292 |
5efc23d83bc2
Added the ngx_http_test_required_predicates() function.
Vladimir Homutov <vl@nginx.com>
parents:
7271
diff
changeset
|
293 if (val.len == 0 || (val.len == 1 && val.data[0] == '0')) { |
5efc23d83bc2
Added the ngx_http_test_required_predicates() function.
Vladimir Homutov <vl@nginx.com>
parents:
7271
diff
changeset
|
294 return NGX_DECLINED; |
5efc23d83bc2
Added the ngx_http_test_required_predicates() function.
Vladimir Homutov <vl@nginx.com>
parents:
7271
diff
changeset
|
295 } |
5efc23d83bc2
Added the ngx_http_test_required_predicates() function.
Vladimir Homutov <vl@nginx.com>
parents:
7271
diff
changeset
|
296 } |
5efc23d83bc2
Added the ngx_http_test_required_predicates() function.
Vladimir Homutov <vl@nginx.com>
parents:
7271
diff
changeset
|
297 |
5efc23d83bc2
Added the ngx_http_test_required_predicates() function.
Vladimir Homutov <vl@nginx.com>
parents:
7271
diff
changeset
|
298 return NGX_OK; |
5efc23d83bc2
Added the ngx_http_test_required_predicates() function.
Vladimir Homutov <vl@nginx.com>
parents:
7271
diff
changeset
|
299 } |
5efc23d83bc2
Added the ngx_http_test_required_predicates() function.
Vladimir Homutov <vl@nginx.com>
parents:
7271
diff
changeset
|
300 |
5efc23d83bc2
Added the ngx_http_test_required_predicates() function.
Vladimir Homutov <vl@nginx.com>
parents:
7271
diff
changeset
|
301 |
3691
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
302 char * |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
303 ngx_http_set_predicate_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
304 { |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
305 char *p = conf; |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
306 |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
307 ngx_str_t *value; |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
308 ngx_uint_t i; |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
309 ngx_array_t **a; |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
310 ngx_http_complex_value_t *cv; |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
311 ngx_http_compile_complex_value_t ccv; |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
312 |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
313 a = (ngx_array_t **) (p + cmd->offset); |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
314 |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
315 if (*a == NGX_CONF_UNSET_PTR) { |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
316 *a = ngx_array_create(cf->pool, 1, sizeof(ngx_http_complex_value_t)); |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
317 if (*a == NULL) { |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
318 return NGX_CONF_ERROR; |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
319 } |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
320 } |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
321 |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
322 value = cf->args->elts; |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
323 |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
324 for (i = 1; i < cf->args->nelts; i++) { |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
325 cv = ngx_array_push(*a); |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
326 if (cv == NULL) { |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
327 return NGX_CONF_ERROR; |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
328 } |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
329 |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
330 ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
331 |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
332 ccv.cf = cf; |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
333 ccv.value = &value[i]; |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
334 ccv.complex_value = cv; |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
335 |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
336 if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
337 return NGX_CONF_ERROR; |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
338 } |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
339 } |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
340 |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
341 return NGX_CONF_OK; |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
342 } |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
343 |
55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3633
diff
changeset
|
344 |
509 | 345 ngx_uint_t |
346 ngx_http_script_variables_count(ngx_str_t *value) | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
347 { |
509 | 348 ngx_uint_t i, n; |
507 | 349 |
509 | 350 for (n = 0, i = 0; i < value->len; i++) { |
351 if (value->data[i] == '$') { | |
352 n++; | |
353 } | |
507 | 354 } |
355 | |
509 | 356 return n; |
357 } | |
358 | |
359 | |
360 ngx_int_t | |
361 ngx_http_script_compile(ngx_http_script_compile_t *sc) | |
362 { | |
2577
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
363 u_char ch; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
364 ngx_str_t name; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
365 ngx_uint_t i, bracket; |
573 | 366 |
2577
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
367 if (ngx_http_script_init_arrays(sc) != NGX_OK) { |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
368 return NGX_ERROR; |
509 | 369 } |
370 | |
371 for (i = 0; i < sc->source->len; /* void */ ) { | |
372 | |
373 name.len = 0; | |
374 | |
375 if (sc->source->data[i] == '$') { | |
376 | |
377 if (++i == sc->source->len) { | |
378 goto invalid_variable; | |
379 } | |
380 | |
6644
af642539cd53
Fixed regex captures handling without PCRE.
Vladimir Homutov <vl@nginx.com>
parents:
6480
diff
changeset
|
381 if (sc->source->data[i] >= '1' && sc->source->data[i] <= '9') { |
2547
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
382 #if (NGX_PCRE) |
6644
af642539cd53
Fixed regex captures handling without PCRE.
Vladimir Homutov <vl@nginx.com>
parents:
6480
diff
changeset
|
383 ngx_uint_t n; |
509 | 384 |
641 | 385 n = sc->source->data[i] - '0'; |
386 | |
6861
e4590dfd97ff
Win32: support 64-bit compilation with MSVC.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6644
diff
changeset
|
387 if (sc->captures_mask & ((ngx_uint_t) 1 << n)) { |
641 | 388 sc->dup_capture = 1; |
389 } | |
390 | |
6861
e4590dfd97ff
Win32: support 64-bit compilation with MSVC.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6644
diff
changeset
|
391 sc->captures_mask |= (ngx_uint_t) 1 << n; |
641 | 392 |
2577
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
393 if (ngx_http_script_add_capture_code(sc, n) != NGX_OK) { |
509 | 394 return NGX_ERROR; |
395 } | |
396 | |
397 i++; | |
398 | |
399 continue; | |
6644
af642539cd53
Fixed regex captures handling without PCRE.
Vladimir Homutov <vl@nginx.com>
parents:
6480
diff
changeset
|
400 #else |
af642539cd53
Fixed regex captures handling without PCRE.
Vladimir Homutov <vl@nginx.com>
parents:
6480
diff
changeset
|
401 ngx_conf_log_error(NGX_LOG_EMERG, sc->cf, 0, |
af642539cd53
Fixed regex captures handling without PCRE.
Vladimir Homutov <vl@nginx.com>
parents:
6480
diff
changeset
|
402 "using variable \"$%c\" requires " |
af642539cd53
Fixed regex captures handling without PCRE.
Vladimir Homutov <vl@nginx.com>
parents:
6480
diff
changeset
|
403 "PCRE library", sc->source->data[i]); |
af642539cd53
Fixed regex captures handling without PCRE.
Vladimir Homutov <vl@nginx.com>
parents:
6480
diff
changeset
|
404 return NGX_ERROR; |
af642539cd53
Fixed regex captures handling without PCRE.
Vladimir Homutov <vl@nginx.com>
parents:
6480
diff
changeset
|
405 #endif |
2577
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
406 } |
2547
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
407 |
509 | 408 if (sc->source->data[i] == '{') { |
409 bracket = 1; | |
410 | |
411 if (++i == sc->source->len) { | |
412 goto invalid_variable; | |
413 } | |
414 | |
415 name.data = &sc->source->data[i]; | |
416 | |
417 } else { | |
418 bracket = 0; | |
419 name.data = &sc->source->data[i]; | |
420 } | |
421 | |
422 for ( /* void */ ; i < sc->source->len; i++, name.len++) { | |
423 ch = sc->source->data[i]; | |
507 | 424 |
509 | 425 if (ch == '}' && bracket) { |
426 i++; | |
427 bracket = 0; | |
428 break; | |
429 } | |
430 | |
431 if ((ch >= 'A' && ch <= 'Z') | |
432 || (ch >= 'a' && ch <= 'z') | |
433 || (ch >= '0' && ch <= '9') | |
434 || ch == '_') | |
435 { | |
436 continue; | |
437 } | |
438 | |
439 break; | |
440 } | |
441 | |
442 if (bracket) { | |
443 ngx_conf_log_error(NGX_LOG_EMERG, sc->cf, 0, | |
444 "the closing bracket in \"%V\" " | |
445 "variable is missing", &name); | |
507 | 446 return NGX_ERROR; |
447 } | |
448 | |
509 | 449 if (name.len == 0) { |
450 goto invalid_variable; | |
451 } | |
507 | 452 |
509 | 453 sc->variables++; |
507 | 454 |
2577
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
455 if (ngx_http_script_add_var_code(sc, &name) != NGX_OK) { |
507 | 456 return NGX_ERROR; |
457 } | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
458 |
509 | 459 continue; |
460 } | |
507 | 461 |
509 | 462 if (sc->source->data[i] == '?' && sc->compile_args) { |
463 sc->args = 1; | |
464 sc->compile_args = 0; | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
465 |
2577
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
466 if (ngx_http_script_add_args_code(sc) != NGX_OK) { |
1891
782af1038115
length calculation did not take into account escaped symbols in arguments
Igor Sysoev <igor@sysoev.ru>
parents:
1799
diff
changeset
|
467 return NGX_ERROR; |
782af1038115
length calculation did not take into account escaped symbols in arguments
Igor Sysoev <igor@sysoev.ru>
parents:
1799
diff
changeset
|
468 } |
782af1038115
length calculation did not take into account escaped symbols in arguments
Igor Sysoev <igor@sysoev.ru>
parents:
1799
diff
changeset
|
469 |
509 | 470 i++; |
471 | |
507 | 472 continue; |
473 } | |
474 | |
509 | 475 name.data = &sc->source->data[i]; |
476 | |
2498
d3357bf23a5e
fix /?new=arg?old=arg redirect case
Igor Sysoev <igor@sysoev.ru>
parents:
2397
diff
changeset
|
477 while (i < sc->source->len) { |
d3357bf23a5e
fix /?new=arg?old=arg redirect case
Igor Sysoev <igor@sysoev.ru>
parents:
2397
diff
changeset
|
478 |
d3357bf23a5e
fix /?new=arg?old=arg redirect case
Igor Sysoev <igor@sysoev.ru>
parents:
2397
diff
changeset
|
479 if (sc->source->data[i] == '$') { |
d3357bf23a5e
fix /?new=arg?old=arg redirect case
Igor Sysoev <igor@sysoev.ru>
parents:
2397
diff
changeset
|
480 break; |
d3357bf23a5e
fix /?new=arg?old=arg redirect case
Igor Sysoev <igor@sysoev.ru>
parents:
2397
diff
changeset
|
481 } |
d3357bf23a5e
fix /?new=arg?old=arg redirect case
Igor Sysoev <igor@sysoev.ru>
parents:
2397
diff
changeset
|
482 |
d3357bf23a5e
fix /?new=arg?old=arg redirect case
Igor Sysoev <igor@sysoev.ru>
parents:
2397
diff
changeset
|
483 if (sc->source->data[i] == '?') { |
d3357bf23a5e
fix /?new=arg?old=arg redirect case
Igor Sysoev <igor@sysoev.ru>
parents:
2397
diff
changeset
|
484 |
d3357bf23a5e
fix /?new=arg?old=arg redirect case
Igor Sysoev <igor@sysoev.ru>
parents:
2397
diff
changeset
|
485 sc->args = 1; |
d3357bf23a5e
fix /?new=arg?old=arg redirect case
Igor Sysoev <igor@sysoev.ru>
parents:
2397
diff
changeset
|
486 |
d3357bf23a5e
fix /?new=arg?old=arg redirect case
Igor Sysoev <igor@sysoev.ru>
parents:
2397
diff
changeset
|
487 if (sc->compile_args) { |
d3357bf23a5e
fix /?new=arg?old=arg redirect case
Igor Sysoev <igor@sysoev.ru>
parents:
2397
diff
changeset
|
488 break; |
d3357bf23a5e
fix /?new=arg?old=arg redirect case
Igor Sysoev <igor@sysoev.ru>
parents:
2397
diff
changeset
|
489 } |
d3357bf23a5e
fix /?new=arg?old=arg redirect case
Igor Sysoev <igor@sysoev.ru>
parents:
2397
diff
changeset
|
490 } |
d3357bf23a5e
fix /?new=arg?old=arg redirect case
Igor Sysoev <igor@sysoev.ru>
parents:
2397
diff
changeset
|
491 |
509 | 492 i++; |
493 name.len++; | |
494 } | |
495 | |
496 sc->size += name.len; | |
497 | |
2587
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
498 if (ngx_http_script_add_copy_code(sc, &name, (i == sc->source->len)) |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
499 != NGX_OK) |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
500 { |
509 | 501 return NGX_ERROR; |
502 } | |
507 | 503 } |
504 | |
2577
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
505 return ngx_http_script_done(sc); |
509 | 506 |
507 invalid_variable: | |
508 | |
509 ngx_conf_log_error(NGX_LOG_EMERG, sc->cf, 0, "invalid variable name"); | |
510 | |
511 return NGX_ERROR; | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
512 } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
513 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
514 |
623 | 515 u_char * |
516 ngx_http_script_run(ngx_http_request_t *r, ngx_str_t *value, | |
517 void *code_lengths, size_t len, void *code_values) | |
518 { | |
1152
a9715f8f17a5
flush nocachable variables before ngx_http_script_run()
Igor Sysoev <igor@sysoev.ru>
parents:
845
diff
changeset
|
519 ngx_uint_t i; |
a9715f8f17a5
flush nocachable variables before ngx_http_script_run()
Igor Sysoev <igor@sysoev.ru>
parents:
845
diff
changeset
|
520 ngx_http_script_code_pt code; |
a9715f8f17a5
flush nocachable variables before ngx_http_script_run()
Igor Sysoev <igor@sysoev.ru>
parents:
845
diff
changeset
|
521 ngx_http_script_len_code_pt lcode; |
a9715f8f17a5
flush nocachable variables before ngx_http_script_run()
Igor Sysoev <igor@sysoev.ru>
parents:
845
diff
changeset
|
522 ngx_http_script_engine_t e; |
a9715f8f17a5
flush nocachable variables before ngx_http_script_run()
Igor Sysoev <igor@sysoev.ru>
parents:
845
diff
changeset
|
523 ngx_http_core_main_conf_t *cmcf; |
a9715f8f17a5
flush nocachable variables before ngx_http_script_run()
Igor Sysoev <igor@sysoev.ru>
parents:
845
diff
changeset
|
524 |
a9715f8f17a5
flush nocachable variables before ngx_http_script_run()
Igor Sysoev <igor@sysoev.ru>
parents:
845
diff
changeset
|
525 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); |
a9715f8f17a5
flush nocachable variables before ngx_http_script_run()
Igor Sysoev <igor@sysoev.ru>
parents:
845
diff
changeset
|
526 |
a9715f8f17a5
flush nocachable variables before ngx_http_script_run()
Igor Sysoev <igor@sysoev.ru>
parents:
845
diff
changeset
|
527 for (i = 0; i < cmcf->variables.nelts; i++) { |
1565 | 528 if (r->variables[i].no_cacheable) { |
1152
a9715f8f17a5
flush nocachable variables before ngx_http_script_run()
Igor Sysoev <igor@sysoev.ru>
parents:
845
diff
changeset
|
529 r->variables[i].valid = 0; |
a9715f8f17a5
flush nocachable variables before ngx_http_script_run()
Igor Sysoev <igor@sysoev.ru>
parents:
845
diff
changeset
|
530 r->variables[i].not_found = 0; |
a9715f8f17a5
flush nocachable variables before ngx_http_script_run()
Igor Sysoev <igor@sysoev.ru>
parents:
845
diff
changeset
|
531 } |
a9715f8f17a5
flush nocachable variables before ngx_http_script_run()
Igor Sysoev <igor@sysoev.ru>
parents:
845
diff
changeset
|
532 } |
623 | 533 |
534 ngx_memzero(&e, sizeof(ngx_http_script_engine_t)); | |
535 | |
536 e.ip = code_lengths; | |
537 e.request = r; | |
538 e.flushed = 1; | |
539 | |
540 while (*(uintptr_t *) e.ip) { | |
541 lcode = *(ngx_http_script_len_code_pt *) e.ip; | |
542 len += lcode(&e); | |
543 } | |
544 | |
545 | |
546 value->len = len; | |
2049 | 547 value->data = ngx_pnalloc(r->pool, len); |
623 | 548 if (value->data == NULL) { |
549 return NULL; | |
550 } | |
551 | |
552 e.ip = code_values; | |
553 e.pos = value->data; | |
554 | |
555 while (*(uintptr_t *) e.ip) { | |
556 code = *(ngx_http_script_code_pt *) e.ip; | |
557 code((ngx_http_script_engine_t *) &e); | |
558 } | |
559 | |
560 return e.pos; | |
561 } | |
562 | |
563 | |
573 | 564 void |
1565 | 565 ngx_http_script_flush_no_cacheable_variables(ngx_http_request_t *r, |
573 | 566 ngx_array_t *indices) |
567 { | |
568 ngx_uint_t n, *index; | |
569 | |
570 if (indices) { | |
571 index = indices->elts; | |
572 for (n = 0; n < indices->nelts; n++) { | |
1565 | 573 if (r->variables[index[n]].no_cacheable) { |
573 | 574 r->variables[index[n]].valid = 0; |
575 r->variables[index[n]].not_found = 0; | |
576 } | |
577 } | |
578 } | |
579 } | |
580 | |
581 | |
2577
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
582 static ngx_int_t |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
583 ngx_http_script_init_arrays(ngx_http_script_compile_t *sc) |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
584 { |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
585 ngx_uint_t n; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
586 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
587 if (sc->flushes && *sc->flushes == NULL) { |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
588 n = sc->variables ? sc->variables : 1; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
589 *sc->flushes = ngx_array_create(sc->cf->pool, n, sizeof(ngx_uint_t)); |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
590 if (*sc->flushes == NULL) { |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
591 return NGX_ERROR; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
592 } |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
593 } |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
594 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
595 if (*sc->lengths == NULL) { |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
596 n = sc->variables * (2 * sizeof(ngx_http_script_copy_code_t) |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
597 + sizeof(ngx_http_script_var_code_t)) |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
598 + sizeof(uintptr_t); |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
599 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
600 *sc->lengths = ngx_array_create(sc->cf->pool, n, 1); |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
601 if (*sc->lengths == NULL) { |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
602 return NGX_ERROR; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
603 } |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
604 } |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
605 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
606 if (*sc->values == NULL) { |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
607 n = (sc->variables * (2 * sizeof(ngx_http_script_copy_code_t) |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
608 + sizeof(ngx_http_script_var_code_t)) |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
609 + sizeof(uintptr_t) |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
610 + sc->source->len |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
611 + sizeof(uintptr_t) - 1) |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
612 & ~(sizeof(uintptr_t) - 1); |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
613 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
614 *sc->values = ngx_array_create(sc->cf->pool, n, 1); |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
615 if (*sc->values == NULL) { |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
616 return NGX_ERROR; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
617 } |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
618 } |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
619 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
620 sc->variables = 0; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
621 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
622 return NGX_OK; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
623 } |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
624 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
625 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
626 static ngx_int_t |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
627 ngx_http_script_done(ngx_http_script_compile_t *sc) |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
628 { |
2587
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
629 ngx_str_t zero; |
2577
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
630 uintptr_t *code; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
631 |
2587
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
632 if (sc->zero) { |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
633 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
634 zero.len = 1; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
635 zero.data = (u_char *) "\0"; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
636 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
637 if (ngx_http_script_add_copy_code(sc, &zero, 0) != NGX_OK) { |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
638 return NGX_ERROR; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
639 } |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
640 } |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
641 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
642 if (sc->conf_prefix || sc->root_prefix) { |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
643 if (ngx_http_script_add_full_name_code(sc) != NGX_OK) { |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
644 return NGX_ERROR; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
645 } |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
646 } |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
647 |
2577
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
648 if (sc->complete_lengths) { |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
649 code = ngx_http_script_add_code(*sc->lengths, sizeof(uintptr_t), NULL); |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
650 if (code == NULL) { |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
651 return NGX_ERROR; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
652 } |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
653 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
654 *code = (uintptr_t) NULL; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
655 } |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
656 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
657 if (sc->complete_values) { |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
658 code = ngx_http_script_add_code(*sc->values, sizeof(uintptr_t), |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
659 &sc->main); |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
660 if (code == NULL) { |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
661 return NGX_ERROR; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
662 } |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
663 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
664 *code = (uintptr_t) NULL; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
665 } |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
666 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
667 return NGX_OK; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
668 } |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
669 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
670 |
509 | 671 void * |
507 | 672 ngx_http_script_start_code(ngx_pool_t *pool, ngx_array_t **codes, size_t size) |
479 | 673 { |
507 | 674 if (*codes == NULL) { |
675 *codes = ngx_array_create(pool, 256, 1); | |
676 if (*codes == NULL) { | |
677 return NULL; | |
678 } | |
679 } | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
680 |
507 | 681 return ngx_array_push_n(*codes, size); |
682 } | |
683 | |
509 | 684 |
685 void * | |
686 ngx_http_script_add_code(ngx_array_t *codes, size_t size, void *code) | |
687 { | |
688 u_char *elts, **p; | |
689 void *new; | |
690 | |
691 elts = codes->elts; | |
692 | |
693 new = ngx_array_push_n(codes, size); | |
694 if (new == NULL) { | |
2911 | 695 return NULL; |
509 | 696 } |
697 | |
698 if (code) { | |
699 if (elts != codes->elts) { | |
700 p = code; | |
701 *p += (u_char *) codes->elts - elts; | |
702 } | |
703 } | |
704 | |
705 return new; | |
706 } | |
507 | 707 |
479 | 708 |
2577
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
709 static ngx_int_t |
2587
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
710 ngx_http_script_add_copy_code(ngx_http_script_compile_t *sc, ngx_str_t *value, |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
711 ngx_uint_t last) |
2577
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
712 { |
2587
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
713 u_char *p; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
714 size_t size, len, zero; |
2577
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
715 ngx_http_script_copy_code_t *code; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
716 |
2587
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
717 zero = (sc->zero && last); |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
718 len = value->len + zero; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
719 |
2577
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
720 code = ngx_http_script_add_code(*sc->lengths, |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
721 sizeof(ngx_http_script_copy_code_t), NULL); |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
722 if (code == NULL) { |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
723 return NGX_ERROR; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
724 } |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
725 |
7271
9e25a5380a21
Silenced -Wcast-function-type warnings (closes #1546).
Sergey Kandaurov <pluknet@nginx.com>
parents:
6948
diff
changeset
|
726 code->code = (ngx_http_script_code_pt) (void *) |
9e25a5380a21
Silenced -Wcast-function-type warnings (closes #1546).
Sergey Kandaurov <pluknet@nginx.com>
parents:
6948
diff
changeset
|
727 ngx_http_script_copy_len_code; |
2587
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
728 code->len = len; |
2577
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
729 |
2587
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
730 size = (sizeof(ngx_http_script_copy_code_t) + len + sizeof(uintptr_t) - 1) |
2577
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
731 & ~(sizeof(uintptr_t) - 1); |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
732 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
733 code = ngx_http_script_add_code(*sc->values, size, &sc->main); |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
734 if (code == NULL) { |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
735 return NGX_ERROR; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
736 } |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
737 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
738 code->code = ngx_http_script_copy_code; |
2587
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
739 code->len = len; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
740 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
741 p = ngx_cpymem((u_char *) code + sizeof(ngx_http_script_copy_code_t), |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
742 value->data, value->len); |
2577
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
743 |
2587
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
744 if (zero) { |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
745 *p = '\0'; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
746 sc->zero = 0; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
747 } |
2577
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
748 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
749 return NGX_OK; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
750 } |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
751 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
752 |
507 | 753 size_t |
509 | 754 ngx_http_script_copy_len_code(ngx_http_script_engine_t *e) |
507 | 755 { |
756 ngx_http_script_copy_code_t *code; | |
479 | 757 |
509 | 758 code = (ngx_http_script_copy_code_t *) e->ip; |
507 | 759 |
509 | 760 e->ip += sizeof(ngx_http_script_copy_code_t); |
507 | 761 |
762 return code->len; | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
763 } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
764 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
765 |
507 | 766 void |
509 | 767 ngx_http_script_copy_code(ngx_http_script_engine_t *e) |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
768 { |
2393 | 769 u_char *p; |
507 | 770 ngx_http_script_copy_code_t *code; |
771 | |
509 | 772 code = (ngx_http_script_copy_code_t *) e->ip; |
773 | |
2393 | 774 p = e->pos; |
775 | |
509 | 776 if (!e->skip) { |
2393 | 777 e->pos = ngx_copy(p, e->ip + sizeof(ngx_http_script_copy_code_t), |
573 | 778 code->len); |
509 | 779 } |
507 | 780 |
509 | 781 e->ip += sizeof(ngx_http_script_copy_code_t) |
782 + ((code->len + sizeof(uintptr_t) - 1) & ~(sizeof(uintptr_t) - 1)); | |
507 | 783 |
2393 | 784 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0, |
785 "http script copy: \"%*s\"", e->pos - p, p); | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
786 } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
787 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
788 |
2577
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
789 static ngx_int_t |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
790 ngx_http_script_add_var_code(ngx_http_script_compile_t *sc, ngx_str_t *name) |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
791 { |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
792 ngx_int_t index, *p; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
793 ngx_http_script_var_code_t *code; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
794 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
795 index = ngx_http_get_variable_index(sc->cf, name); |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
796 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
797 if (index == NGX_ERROR) { |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
798 return NGX_ERROR; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
799 } |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
800 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
801 if (sc->flushes) { |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
802 p = ngx_array_push(*sc->flushes); |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
803 if (p == NULL) { |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
804 return NGX_ERROR; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
805 } |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
806 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
807 *p = index; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
808 } |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
809 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
810 code = ngx_http_script_add_code(*sc->lengths, |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
811 sizeof(ngx_http_script_var_code_t), NULL); |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
812 if (code == NULL) { |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
813 return NGX_ERROR; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
814 } |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
815 |
7271
9e25a5380a21
Silenced -Wcast-function-type warnings (closes #1546).
Sergey Kandaurov <pluknet@nginx.com>
parents:
6948
diff
changeset
|
816 code->code = (ngx_http_script_code_pt) (void *) |
9e25a5380a21
Silenced -Wcast-function-type warnings (closes #1546).
Sergey Kandaurov <pluknet@nginx.com>
parents:
6948
diff
changeset
|
817 ngx_http_script_copy_var_len_code; |
2577
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
818 code->index = (uintptr_t) index; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
819 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
820 code = ngx_http_script_add_code(*sc->values, |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
821 sizeof(ngx_http_script_var_code_t), |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
822 &sc->main); |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
823 if (code == NULL) { |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
824 return NGX_ERROR; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
825 } |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
826 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
827 code->code = ngx_http_script_copy_var_code; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
828 code->index = (uintptr_t) index; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
829 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
830 return NGX_OK; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
831 } |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
832 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
833 |
507 | 834 size_t |
509 | 835 ngx_http_script_copy_var_len_code(ngx_http_script_engine_t *e) |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
836 { |
507 | 837 ngx_http_variable_value_t *value; |
838 ngx_http_script_var_code_t *code; | |
839 | |
509 | 840 code = (ngx_http_script_var_code_t *) e->ip; |
507 | 841 |
509 | 842 e->ip += sizeof(ngx_http_script_var_code_t); |
507 | 843 |
573 | 844 if (e->flushed) { |
845 value = ngx_http_get_indexed_variable(e->request, code->index); | |
507 | 846 |
573 | 847 } else { |
848 value = ngx_http_get_flushed_variable(e->request, code->index); | |
849 } | |
850 | |
851 if (value && !value->not_found) { | |
852 return value->len; | |
507 | 853 } |
854 | |
553 | 855 return 0; |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
856 } |
479 | 857 |
858 | |
507 | 859 void |
509 | 860 ngx_http_script_copy_var_code(ngx_http_script_engine_t *e) |
479 | 861 { |
2393 | 862 u_char *p; |
507 | 863 ngx_http_variable_value_t *value; |
864 ngx_http_script_var_code_t *code; | |
865 | |
509 | 866 code = (ngx_http_script_var_code_t *) e->ip; |
867 | |
868 e->ip += sizeof(ngx_http_script_var_code_t); | |
869 | |
870 if (!e->skip) { | |
573 | 871 |
872 if (e->flushed) { | |
873 value = ngx_http_get_indexed_variable(e->request, code->index); | |
509 | 874 |
573 | 875 } else { |
876 value = ngx_http_get_flushed_variable(e->request, code->index); | |
877 } | |
878 | |
879 if (value && !value->not_found) { | |
2393 | 880 p = e->pos; |
881 e->pos = ngx_copy(p, value->data, value->len); | |
509 | 882 |
2393 | 883 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, |
845
eb5cf273e5d2
debug log should not be under rewrite_log control
Igor Sysoev <igor@sysoev.ru>
parents:
730
diff
changeset
|
884 e->request->connection->log, 0, |
2393 | 885 "http script var: \"%*s\"", e->pos - p, p); |
509 | 886 } |
887 } | |
888 } | |
889 | |
890 | |
2577
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
891 static ngx_int_t |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
892 ngx_http_script_add_args_code(ngx_http_script_compile_t *sc) |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
893 { |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
894 uintptr_t *code; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
895 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
896 code = ngx_http_script_add_code(*sc->lengths, sizeof(uintptr_t), NULL); |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
897 if (code == NULL) { |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
898 return NGX_ERROR; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
899 } |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
900 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
901 *code = (uintptr_t) ngx_http_script_mark_args_code; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
902 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
903 code = ngx_http_script_add_code(*sc->values, sizeof(uintptr_t), &sc->main); |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
904 if (code == NULL) { |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
905 return NGX_ERROR; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
906 } |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
907 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
908 *code = (uintptr_t) ngx_http_script_start_args_code; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
909 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
910 return NGX_OK; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
911 } |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
912 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
913 |
509 | 914 size_t |
1891
782af1038115
length calculation did not take into account escaped symbols in arguments
Igor Sysoev <igor@sysoev.ru>
parents:
1799
diff
changeset
|
915 ngx_http_script_mark_args_code(ngx_http_script_engine_t *e) |
782af1038115
length calculation did not take into account escaped symbols in arguments
Igor Sysoev <igor@sysoev.ru>
parents:
1799
diff
changeset
|
916 { |
782af1038115
length calculation did not take into account escaped symbols in arguments
Igor Sysoev <igor@sysoev.ru>
parents:
1799
diff
changeset
|
917 e->is_args = 1; |
782af1038115
length calculation did not take into account escaped symbols in arguments
Igor Sysoev <igor@sysoev.ru>
parents:
1799
diff
changeset
|
918 e->ip += sizeof(uintptr_t); |
782af1038115
length calculation did not take into account escaped symbols in arguments
Igor Sysoev <igor@sysoev.ru>
parents:
1799
diff
changeset
|
919 |
782af1038115
length calculation did not take into account escaped symbols in arguments
Igor Sysoev <igor@sysoev.ru>
parents:
1799
diff
changeset
|
920 return 1; |
782af1038115
length calculation did not take into account escaped symbols in arguments
Igor Sysoev <igor@sysoev.ru>
parents:
1799
diff
changeset
|
921 } |
782af1038115
length calculation did not take into account escaped symbols in arguments
Igor Sysoev <igor@sysoev.ru>
parents:
1799
diff
changeset
|
922 |
782af1038115
length calculation did not take into account escaped symbols in arguments
Igor Sysoev <igor@sysoev.ru>
parents:
1799
diff
changeset
|
923 |
509 | 924 void |
925 ngx_http_script_start_args_code(ngx_http_script_engine_t *e) | |
926 { | |
927 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0, | |
928 "http script args"); | |
577 | 929 |
2225
207827f7bf71
escape a query string characters taken from URI while rewrite
Igor Sysoev <igor@sysoev.ru>
parents:
2133
diff
changeset
|
930 e->is_args = 1; |
509 | 931 e->args = e->pos; |
932 e->ip += sizeof(uintptr_t); | |
933 } | |
934 | |
935 | |
517 | 936 #if (NGX_PCRE) |
937 | |
509 | 938 void |
939 ngx_http_script_regex_start_code(ngx_http_script_engine_t *e) | |
940 { | |
941 size_t len; | |
942 ngx_int_t rc; | |
943 ngx_uint_t n; | |
944 ngx_http_request_t *r; | |
945 ngx_http_script_engine_t le; | |
946 ngx_http_script_len_code_pt lcode; | |
947 ngx_http_script_regex_code_t *code; | |
948 | |
949 code = (ngx_http_script_regex_code_t *) e->ip; | |
950 | |
951 r = e->request; | |
952 | |
953 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
954 "http script regex: \"%V\"", &code->name); | |
955 | |
956 if (code->uri) { | |
515 | 957 e->line = r->uri; |
509 | 958 } else { |
959 e->sp--; | |
573 | 960 e->line.len = e->sp->len; |
961 e->line.data = e->sp->data; | |
509 | 962 } |
507 | 963 |
3325 | 964 rc = ngx_http_regex_exec(r, code->regex, &e->line); |
2547
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
965 |
3325 | 966 if (rc == NGX_DECLINED) { |
2397 | 967 if (e->log || (r->connection->log->log_level & NGX_LOG_DEBUG_HTTP)) { |
509 | 968 ngx_log_error(NGX_LOG_NOTICE, r->connection->log, 0, |
515 | 969 "\"%V\" does not match \"%V\"", |
970 &code->name, &e->line); | |
509 | 971 } |
972 | |
2547
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
973 r->ncaptures = 0; |
515 | 974 |
509 | 975 if (code->test) { |
631 | 976 if (code->negative_test) { |
977 e->sp->len = 1; | |
978 e->sp->data = (u_char *) "1"; | |
979 | |
980 } else { | |
981 e->sp->len = 0; | |
982 e->sp->data = (u_char *) ""; | |
983 } | |
984 | |
509 | 985 e->sp++; |
986 | |
987 e->ip += sizeof(ngx_http_script_regex_code_t); | |
988 return; | |
989 } | |
990 | |
991 e->ip += code->next; | |
992 return; | |
993 } | |
994 | |
3325 | 995 if (rc == NGX_ERROR) { |
509 | 996 e->ip = ngx_http_script_exit; |
997 e->status = NGX_HTTP_INTERNAL_SERVER_ERROR; | |
998 return; | |
999 } | |
1000 | |
2397 | 1001 if (e->log || (r->connection->log->log_level & NGX_LOG_DEBUG_HTTP)) { |
509 | 1002 ngx_log_error(NGX_LOG_NOTICE, r->connection->log, 0, |
515 | 1003 "\"%V\" matches \"%V\"", &code->name, &e->line); |
509 | 1004 } |
1005 | |
1006 if (code->test) { | |
631 | 1007 if (code->negative_test) { |
1008 e->sp->len = 0; | |
1009 e->sp->data = (u_char *) ""; | |
1010 | |
1011 } else { | |
1012 e->sp->len = 1; | |
1013 e->sp->data = (u_char *) "1"; | |
1014 } | |
1015 | |
509 | 1016 e->sp++; |
1017 | |
1018 e->ip += sizeof(ngx_http_script_regex_code_t); | |
1019 return; | |
1020 } | |
1021 | |
1022 if (code->status) { | |
1023 e->status = code->status; | |
507 | 1024 |
509 | 1025 if (!code->redirect) { |
1026 e->ip = ngx_http_script_exit; | |
1027 return; | |
1028 } | |
1029 } | |
1030 | |
1031 if (code->uri) { | |
1032 r->internal = 1; | |
1033 r->valid_unparsed_uri = 0; | |
1034 | |
1035 if (code->break_cycle) { | |
1036 r->valid_location = 0; | |
527 | 1037 r->uri_changed = 0; |
509 | 1038 |
1039 } else { | |
1040 r->uri_changed = 1; | |
1041 } | |
1042 } | |
1043 | |
1044 if (code->lengths == NULL) { | |
1045 e->buf.len = code->size; | |
1046 | |
1047 if (code->uri) { | |
3344
1aed55182ea2
fix captures in "rewrite", the bug had been introduced in r3326
Igor Sysoev <igor@sysoev.ru>
parents:
3325
diff
changeset
|
1048 if (r->ncaptures && (r->quoted_uri || r->plus_in_uri)) { |
509 | 1049 e->buf.len += 2 * ngx_escape_uri(NULL, r->uri.data, r->uri.len, |
1050 NGX_ESCAPE_ARGS); | |
1051 } | |
1052 } | |
1053 | |
3344
1aed55182ea2
fix captures in "rewrite", the bug had been introduced in r3326
Igor Sysoev <igor@sysoev.ru>
parents:
3325
diff
changeset
|
1054 for (n = 2; n < r->ncaptures; n += 2) { |
1aed55182ea2
fix captures in "rewrite", the bug had been introduced in r3326
Igor Sysoev <igor@sysoev.ru>
parents:
3325
diff
changeset
|
1055 e->buf.len += r->captures[n + 1] - r->captures[n]; |
509 | 1056 } |
1057 | |
1058 } else { | |
1059 ngx_memzero(&le, sizeof(ngx_http_script_engine_t)); | |
1060 | |
1061 le.ip = code->lengths->elts; | |
679 | 1062 le.line = e->line; |
509 | 1063 le.request = r; |
679 | 1064 le.quote = code->redirect; |
509 | 1065 |
1891
782af1038115
length calculation did not take into account escaped symbols in arguments
Igor Sysoev <igor@sysoev.ru>
parents:
1799
diff
changeset
|
1066 len = 0; |
509 | 1067 |
1068 while (*(uintptr_t *) le.ip) { | |
1069 lcode = *(ngx_http_script_len_code_pt *) le.ip; | |
1070 len += lcode(&le); | |
1071 } | |
1072 | |
1073 e->buf.len = len; | |
1074 } | |
1075 | |
515 | 1076 if (code->add_args && r->args.len) { |
509 | 1077 e->buf.len += r->args.len + 1; |
1078 } | |
1079 | |
2049 | 1080 e->buf.data = ngx_pnalloc(r->pool, e->buf.len); |
509 | 1081 if (e->buf.data == NULL) { |
1082 e->ip = ngx_http_script_exit; | |
1083 e->status = NGX_HTTP_INTERNAL_SERVER_ERROR; | |
507 | 1084 return; |
1085 } | |
1086 | |
509 | 1087 e->quote = code->redirect; |
1088 | |
1089 e->pos = e->buf.data; | |
1090 | |
1091 e->ip += sizeof(ngx_http_script_regex_code_t); | |
1092 } | |
1093 | |
1094 | |
1095 void | |
1096 ngx_http_script_regex_end_code(ngx_http_script_engine_t *e) | |
1097 { | |
577 | 1098 u_char *dst, *src; |
509 | 1099 ngx_http_request_t *r; |
1100 ngx_http_script_regex_end_code_t *code; | |
1101 | |
1102 code = (ngx_http_script_regex_end_code_t *) e->ip; | |
1103 | |
1104 r = e->request; | |
1105 | |
1106 e->quote = 0; | |
1107 | |
1108 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1109 "http script regex end"); | |
1110 | |
1111 if (code->redirect) { | |
1112 | |
577 | 1113 dst = e->buf.data; |
1114 src = e->buf.data; | |
1115 | |
1593 | 1116 ngx_unescape_uri(&dst, &src, e->pos - e->buf.data, |
1117 NGX_UNESCAPE_REDIRECT); | |
577 | 1118 |
1119 if (src < e->pos) { | |
3887
e7798b5e990a
use memmove() in appropriate places
Igor Sysoev <igor@sysoev.ru>
parents:
3761
diff
changeset
|
1120 dst = ngx_movemem(dst, src, e->pos - src); |
577 | 1121 } |
1122 | |
1123 e->pos = dst; | |
1124 | |
1125 if (code->add_args && r->args.len) { | |
509 | 1126 *e->pos++ = (u_char) (code->args ? '&' : '?'); |
573 | 1127 e->pos = ngx_copy(e->pos, r->args.data, r->args.len); |
509 | 1128 } |
1129 | |
1130 e->buf.len = e->pos - e->buf.data; | |
1131 | |
2397 | 1132 if (e->log || (r->connection->log->log_level & NGX_LOG_DEBUG_HTTP)) { |
509 | 1133 ngx_log_error(NGX_LOG_NOTICE, r->connection->log, 0, |
1134 "rewritten redirect: \"%V\"", &e->buf); | |
1135 } | |
1136 | |
4206
1a94a56a4e5d
Clear old Location header (if any) while adding a new one.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3904
diff
changeset
|
1137 ngx_http_clear_location(r); |
1a94a56a4e5d
Clear old Location header (if any) while adding a new one.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3904
diff
changeset
|
1138 |
509 | 1139 r->headers_out.location = ngx_list_push(&r->headers_out.headers); |
1140 if (r->headers_out.location == NULL) { | |
1141 e->ip = ngx_http_script_exit; | |
1142 e->status = NGX_HTTP_INTERNAL_SERVER_ERROR; | |
1143 return; | |
1144 } | |
1145 | |
577 | 1146 r->headers_out.location->hash = 1; |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3344
diff
changeset
|
1147 ngx_str_set(&r->headers_out.location->key, "Location"); |
509 | 1148 r->headers_out.location->value = e->buf; |
1149 | |
1150 e->ip += sizeof(ngx_http_script_regex_end_code_t); | |
1151 return; | |
1152 } | |
1153 | |
577 | 1154 if (e->args) { |
509 | 1155 e->buf.len = e->args - e->buf.data; |
1156 | |
1157 if (code->add_args && r->args.len) { | |
1158 *e->pos++ = '&'; | |
573 | 1159 e->pos = ngx_copy(e->pos, r->args.data, r->args.len); |
509 | 1160 } |
1161 | |
1162 r->args.len = e->pos - e->args; | |
1163 r->args.data = e->args; | |
1164 | |
1165 e->args = NULL; | |
1166 | |
1167 } else { | |
1168 e->buf.len = e->pos - e->buf.data; | |
673 | 1169 |
1170 if (!code->add_args) { | |
1171 r->args.len = 0; | |
1172 } | |
509 | 1173 } |
1174 | |
2397 | 1175 if (e->log || (r->connection->log->log_level & NGX_LOG_DEBUG_HTTP)) { |
509 | 1176 ngx_log_error(NGX_LOG_NOTICE, r->connection->log, 0, |
1177 "rewritten data: \"%V\", args: \"%V\"", | |
1178 &e->buf, &r->args); | |
1179 } | |
1180 | |
1181 if (code->uri) { | |
1182 r->uri = e->buf; | |
1183 | |
535 | 1184 if (r->uri.len == 0) { |
1185 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1186 "the rewritten URI has a zero length"); | |
1187 e->ip = ngx_http_script_exit; | |
1188 e->status = NGX_HTTP_INTERNAL_SERVER_ERROR; | |
1189 return; | |
1190 } | |
1191 | |
2979
b941147f2b2e
ngx_http_set_exten() is always successful since 0.3.46
Igor Sysoev <igor@sysoev.ru>
parents:
2911
diff
changeset
|
1192 ngx_http_set_exten(r); |
509 | 1193 } |
1194 | |
1195 e->ip += sizeof(ngx_http_script_regex_end_code_t); | |
1196 } | |
1197 | |
2547
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1198 |
2577
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
1199 static ngx_int_t |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
1200 ngx_http_script_add_capture_code(ngx_http_script_compile_t *sc, ngx_uint_t n) |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
1201 { |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
1202 ngx_http_script_copy_capture_code_t *code; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
1203 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
1204 code = ngx_http_script_add_code(*sc->lengths, |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
1205 sizeof(ngx_http_script_copy_capture_code_t), |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
1206 NULL); |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
1207 if (code == NULL) { |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
1208 return NGX_ERROR; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
1209 } |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
1210 |
7271
9e25a5380a21
Silenced -Wcast-function-type warnings (closes #1546).
Sergey Kandaurov <pluknet@nginx.com>
parents:
6948
diff
changeset
|
1211 code->code = (ngx_http_script_code_pt) (void *) |
9e25a5380a21
Silenced -Wcast-function-type warnings (closes #1546).
Sergey Kandaurov <pluknet@nginx.com>
parents:
6948
diff
changeset
|
1212 ngx_http_script_copy_capture_len_code; |
2577
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
1213 code->n = 2 * n; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
1214 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
1215 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
1216 code = ngx_http_script_add_code(*sc->values, |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
1217 sizeof(ngx_http_script_copy_capture_code_t), |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
1218 &sc->main); |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
1219 if (code == NULL) { |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
1220 return NGX_ERROR; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
1221 } |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
1222 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
1223 code->code = ngx_http_script_copy_capture_code; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
1224 code->n = 2 * n; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
1225 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
1226 if (sc->ncaptures < n) { |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
1227 sc->ncaptures = n; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
1228 } |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
1229 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
1230 return NGX_OK; |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
1231 } |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
1232 |
2dcbcfc1a8d1
split ngx_http_script_compile()
Igor Sysoev <igor@sysoev.ru>
parents:
2547
diff
changeset
|
1233 |
2547
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1234 size_t |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1235 ngx_http_script_copy_capture_len_code(ngx_http_script_engine_t *e) |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1236 { |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1237 int *cap; |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1238 u_char *p; |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1239 ngx_uint_t n; |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1240 ngx_http_request_t *r; |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1241 ngx_http_script_copy_capture_code_t *code; |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1242 |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1243 r = e->request; |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1244 |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1245 code = (ngx_http_script_copy_capture_code_t *) e->ip; |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1246 |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1247 e->ip += sizeof(ngx_http_script_copy_capture_code_t); |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1248 |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1249 n = code->n; |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1250 |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1251 if (n < r->ncaptures) { |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1252 |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1253 cap = r->captures; |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1254 |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1255 if ((e->is_args || e->quote) |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1256 && (e->request->quoted_uri || e->request->plus_in_uri)) |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1257 { |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1258 p = r->captures_data; |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1259 |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1260 return cap[n + 1] - cap[n] |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1261 + 2 * ngx_escape_uri(NULL, &p[cap[n]], cap[n + 1] - cap[n], |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1262 NGX_ESCAPE_ARGS); |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1263 } else { |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1264 return cap[n + 1] - cap[n]; |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1265 } |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1266 } |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1267 |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1268 return 0; |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1269 } |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1270 |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1271 |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1272 void |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1273 ngx_http_script_copy_capture_code(ngx_http_script_engine_t *e) |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1274 { |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1275 int *cap; |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1276 u_char *p, *pos; |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1277 ngx_uint_t n; |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1278 ngx_http_request_t *r; |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1279 ngx_http_script_copy_capture_code_t *code; |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1280 |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1281 r = e->request; |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1282 |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1283 code = (ngx_http_script_copy_capture_code_t *) e->ip; |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1284 |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1285 e->ip += sizeof(ngx_http_script_copy_capture_code_t); |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1286 |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1287 n = code->n; |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1288 |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1289 pos = e->pos; |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1290 |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1291 if (n < r->ncaptures) { |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1292 |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1293 cap = r->captures; |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1294 p = r->captures_data; |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1295 |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1296 if ((e->is_args || e->quote) |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1297 && (e->request->quoted_uri || e->request->plus_in_uri)) |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1298 { |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1299 e->pos = (u_char *) ngx_escape_uri(pos, &p[cap[n]], |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1300 cap[n + 1] - cap[n], |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1301 NGX_ESCAPE_ARGS); |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1302 } else { |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1303 e->pos = ngx_copy(pos, &p[cap[n]], cap[n + 1] - cap[n]); |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1304 } |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1305 } |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1306 |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1307 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0, |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1308 "http script capture: \"%*s\"", e->pos - pos, pos); |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1309 } |
912ce4113f21
now regex captures are per-request entities
Igor Sysoev <igor@sysoev.ru>
parents:
2498
diff
changeset
|
1310 |
517 | 1311 #endif |
1312 | |
509 | 1313 |
2587
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1314 static ngx_int_t |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1315 ngx_http_script_add_full_name_code(ngx_http_script_compile_t *sc) |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1316 { |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1317 ngx_http_script_full_name_code_t *code; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1318 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1319 code = ngx_http_script_add_code(*sc->lengths, |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1320 sizeof(ngx_http_script_full_name_code_t), |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1321 NULL); |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1322 if (code == NULL) { |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1323 return NGX_ERROR; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1324 } |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1325 |
7271
9e25a5380a21
Silenced -Wcast-function-type warnings (closes #1546).
Sergey Kandaurov <pluknet@nginx.com>
parents:
6948
diff
changeset
|
1326 code->code = (ngx_http_script_code_pt) (void *) |
9e25a5380a21
Silenced -Wcast-function-type warnings (closes #1546).
Sergey Kandaurov <pluknet@nginx.com>
parents:
6948
diff
changeset
|
1327 ngx_http_script_full_name_len_code; |
2758 | 1328 code->conf_prefix = sc->conf_prefix; |
2587
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1329 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1330 code = ngx_http_script_add_code(*sc->values, |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1331 sizeof(ngx_http_script_full_name_code_t), |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1332 &sc->main); |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1333 if (code == NULL) { |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1334 return NGX_ERROR; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1335 } |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1336 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1337 code->code = ngx_http_script_full_name_code; |
2758 | 1338 code->conf_prefix = sc->conf_prefix; |
2587
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1339 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1340 return NGX_OK; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1341 } |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1342 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1343 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1344 static size_t |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1345 ngx_http_script_full_name_len_code(ngx_http_script_engine_t *e) |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1346 { |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1347 ngx_http_script_full_name_code_t *code; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1348 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1349 code = (ngx_http_script_full_name_code_t *) e->ip; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1350 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1351 e->ip += sizeof(ngx_http_script_full_name_code_t); |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1352 |
2758 | 1353 return code->conf_prefix ? ngx_cycle->conf_prefix.len: |
1354 ngx_cycle->prefix.len; | |
2587
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1355 } |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1356 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1357 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1358 static void |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1359 ngx_http_script_full_name_code(ngx_http_script_engine_t *e) |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1360 { |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1361 ngx_http_script_full_name_code_t *code; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1362 |
5331
e04083b79335
Style improved after 12dd27b74117.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5330
diff
changeset
|
1363 ngx_str_t value, *prefix; |
2587
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1364 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1365 code = (ngx_http_script_full_name_code_t *) e->ip; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1366 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1367 value.data = e->buf.data; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1368 value.len = e->pos - e->buf.data; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1369 |
5331
e04083b79335
Style improved after 12dd27b74117.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5330
diff
changeset
|
1370 prefix = code->conf_prefix ? (ngx_str_t *) &ngx_cycle->conf_prefix: |
e04083b79335
Style improved after 12dd27b74117.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5330
diff
changeset
|
1371 (ngx_str_t *) &ngx_cycle->prefix; |
e04083b79335
Style improved after 12dd27b74117.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5330
diff
changeset
|
1372 |
e04083b79335
Style improved after 12dd27b74117.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5330
diff
changeset
|
1373 if (ngx_get_full_name(e->request->pool, prefix, &value) != NGX_OK) { |
2587
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1374 e->ip = ngx_http_script_exit; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1375 e->status = NGX_HTTP_INTERNAL_SERVER_ERROR; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1376 return; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1377 } |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1378 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1379 e->buf = value; |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1380 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1381 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0, |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1382 "http script fullname: \"%V\"", &value); |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1383 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1384 e->ip += sizeof(ngx_http_script_full_name_code_t); |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1385 } |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1386 |
8afc4df77ee8
ngx_http_script_flush_complex_value()
Igor Sysoev <igor@sysoev.ru>
parents:
2577
diff
changeset
|
1387 |
509 | 1388 void |
1389 ngx_http_script_return_code(ngx_http_script_engine_t *e) | |
577 | 1390 { |
509 | 1391 ngx_http_script_return_code_t *code; |
577 | 1392 |
509 | 1393 code = (ngx_http_script_return_code_t *) e->ip; |
1394 | |
3633 | 1395 if (code->status < NGX_HTTP_BAD_REQUEST |
1396 || code->text.value.len | |
1397 || code->text.lengths) | |
1398 { | |
1399 e->status = ngx_http_send_response(e->request, code->status, NULL, | |
1400 &code->text); | |
1401 } else { | |
1402 e->status = code->status; | |
653 | 1403 } |
1404 | |
3633 | 1405 e->ip = ngx_http_script_exit; |
479 | 1406 } |
509 | 1407 |
1408 | |
1409 void | |
527 | 1410 ngx_http_script_break_code(ngx_http_script_engine_t *e) |
1411 { | |
1412 e->request->uri_changed = 0; | |
1413 | |
1414 e->ip = ngx_http_script_exit; | |
1415 } | |
1416 | |
1417 | |
1418 void | |
509 | 1419 ngx_http_script_if_code(ngx_http_script_engine_t *e) |
1420 { | |
1421 ngx_http_script_if_code_t *code; | |
1422 | |
1423 code = (ngx_http_script_if_code_t *) e->ip; | |
1424 | |
1425 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0, | |
1426 "http script if"); | |
1427 | |
1428 e->sp--; | |
1429 | |
5426 | 1430 if (e->sp->len && (e->sp->len != 1 || e->sp->data[0] != '0')) { |
509 | 1431 if (code->loc_conf) { |
1432 e->request->loc_conf = code->loc_conf; | |
535 | 1433 ngx_http_update_location_config(e->request); |
509 | 1434 } |
1435 | |
1436 e->ip += sizeof(ngx_http_script_if_code_t); | |
1437 return; | |
1438 } | |
1439 | |
1440 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0, | |
577 | 1441 "http script if: false"); |
509 | 1442 |
1443 e->ip += code->next; | |
1444 } | |
1445 | |
1446 | |
1447 void | |
577 | 1448 ngx_http_script_equal_code(ngx_http_script_engine_t *e) |
1449 { | |
1450 ngx_http_variable_value_t *val, *res; | |
1451 | |
1452 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0, | |
1453 "http script equal"); | |
1454 | |
1455 e->sp--; | |
1456 val = e->sp; | |
1457 res = e->sp - 1; | |
1458 | |
1459 e->ip += sizeof(uintptr_t); | |
1460 | |
2393 | 1461 if (val->len == res->len |
1462 && ngx_strncmp(val->data, res->data, res->len) == 0) | |
577 | 1463 { |
1464 *res = ngx_http_variable_true_value; | |
1465 return; | |
1466 } | |
1467 | |
1468 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0, | |
1469 "http script equal: no"); | |
1470 | |
1471 *res = ngx_http_variable_null_value; | |
1472 } | |
1473 | |
1474 | |
1475 void | |
1476 ngx_http_script_not_equal_code(ngx_http_script_engine_t *e) | |
1477 { | |
1478 ngx_http_variable_value_t *val, *res; | |
1479 | |
1480 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0, | |
1481 "http script not equal"); | |
1482 | |
1483 e->sp--; | |
1484 val = e->sp; | |
1485 res = e->sp - 1; | |
1486 | |
1487 e->ip += sizeof(uintptr_t); | |
1488 | |
2393 | 1489 if (val->len == res->len |
1490 && ngx_strncmp(val->data, res->data, res->len) == 0) | |
577 | 1491 { |
1492 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0, | |
1493 "http script not equal: no"); | |
1494 | |
1495 *res = ngx_http_variable_null_value; | |
1496 return; | |
1497 } | |
1498 | |
1499 *res = ngx_http_variable_true_value; | |
1500 } | |
1501 | |
1502 | |
1503 void | |
631 | 1504 ngx_http_script_file_code(ngx_http_script_engine_t *e) |
1505 { | |
1454 | 1506 ngx_str_t path; |
1507 ngx_http_request_t *r; | |
1508 ngx_open_file_info_t of; | |
1509 ngx_http_core_loc_conf_t *clcf; | |
631 | 1510 ngx_http_variable_value_t *value; |
1511 ngx_http_script_file_code_t *code; | |
1512 | |
1513 value = e->sp - 1; | |
1514 | |
1515 code = (ngx_http_script_file_code_t *) e->ip; | |
1516 e->ip += sizeof(ngx_http_script_file_code_t); | |
1517 | |
1454 | 1518 path.len = value->len - 1; |
1519 path.data = value->data; | |
1520 | |
1521 r = e->request; | |
1522 | |
1523 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
6480 | 1524 "http script file op %p \"%V\"", (void *) code->op, &path); |
1454 | 1525 |
1526 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | |
631 | 1527 |
2068
75a8d34459c5
ngx_memzero() ngx_open_file_info_t
Igor Sysoev <igor@sysoev.ru>
parents:
2063
diff
changeset
|
1528 ngx_memzero(&of, sizeof(ngx_open_file_info_t)); |
75a8d34459c5
ngx_memzero() ngx_open_file_info_t
Igor Sysoev <igor@sysoev.ru>
parents:
2063
diff
changeset
|
1529 |
3178 | 1530 of.read_ahead = clcf->read_ahead; |
2129 | 1531 of.directio = clcf->directio; |
1767
c42431762903
open_file_cache_retest > open_file_cache_valid
Igor Sysoev <igor@sysoev.ru>
parents:
1593
diff
changeset
|
1532 of.valid = clcf->open_file_cache_valid; |
1772 | 1533 of.min_uses = clcf->open_file_cache_min_uses; |
2756
09cab3f8d92e
*) of.test_only to not open file if only stat() is enough
Igor Sysoev <igor@sysoev.ru>
parents:
2609
diff
changeset
|
1534 of.test_only = 1; |
1454 | 1535 of.errors = clcf->open_file_cache_errors; |
1457 | 1536 of.events = clcf->open_file_cache_events; |
4494
13e09cf11d4e
Disable symlinks: initialization of the "disable_symlinks" field in
Valentin Bartenev <vbart@nginx.com>
parents:
4478
diff
changeset
|
1537 |
13e09cf11d4e
Disable symlinks: initialization of the "disable_symlinks" field in
Valentin Bartenev <vbart@nginx.com>
parents:
4478
diff
changeset
|
1538 if (ngx_http_set_disable_symlinks(r, clcf, &path, &of) != NGX_OK) { |
13e09cf11d4e
Disable symlinks: initialization of the "disable_symlinks" field in
Valentin Bartenev <vbart@nginx.com>
parents:
4478
diff
changeset
|
1539 e->ip = ngx_http_script_exit; |
13e09cf11d4e
Disable symlinks: initialization of the "disable_symlinks" field in
Valentin Bartenev <vbart@nginx.com>
parents:
4478
diff
changeset
|
1540 e->status = NGX_HTTP_INTERNAL_SERVER_ERROR; |
13e09cf11d4e
Disable symlinks: initialization of the "disable_symlinks" field in
Valentin Bartenev <vbart@nginx.com>
parents:
4478
diff
changeset
|
1541 return; |
13e09cf11d4e
Disable symlinks: initialization of the "disable_symlinks" field in
Valentin Bartenev <vbart@nginx.com>
parents:
4478
diff
changeset
|
1542 } |
631 | 1543 |
1454 | 1544 if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool) |
1799 | 1545 != NGX_OK) |
1454 | 1546 { |
6948
3fb9b5eb75c0
Fixed ngx_open_cached_file() error handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6940
diff
changeset
|
1547 if (of.err == 0) { |
3fb9b5eb75c0
Fixed ngx_open_cached_file() error handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6940
diff
changeset
|
1548 e->ip = ngx_http_script_exit; |
3fb9b5eb75c0
Fixed ngx_open_cached_file() error handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6940
diff
changeset
|
1549 e->status = NGX_HTTP_INTERNAL_SERVER_ERROR; |
3fb9b5eb75c0
Fixed ngx_open_cached_file() error handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6940
diff
changeset
|
1550 return; |
3fb9b5eb75c0
Fixed ngx_open_cached_file() error handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6940
diff
changeset
|
1551 } |
3fb9b5eb75c0
Fixed ngx_open_cached_file() error handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6940
diff
changeset
|
1552 |
3160
a7637c2c1157
low ENAMETOOLONG logging level
Igor Sysoev <igor@sysoev.ru>
parents:
2979
diff
changeset
|
1553 if (of.err != NGX_ENOENT |
a7637c2c1157
low ENAMETOOLONG logging level
Igor Sysoev <igor@sysoev.ru>
parents:
2979
diff
changeset
|
1554 && of.err != NGX_ENOTDIR |
a7637c2c1157
low ENAMETOOLONG logging level
Igor Sysoev <igor@sysoev.ru>
parents:
2979
diff
changeset
|
1555 && of.err != NGX_ENAMETOOLONG) |
a7637c2c1157
low ENAMETOOLONG logging level
Igor Sysoev <igor@sysoev.ru>
parents:
2979
diff
changeset
|
1556 { |
1454 | 1557 ngx_log_error(NGX_LOG_CRIT, r->connection->log, of.err, |
2756
09cab3f8d92e
*) of.test_only to not open file if only stat() is enough
Igor Sysoev <igor@sysoev.ru>
parents:
2609
diff
changeset
|
1558 "%s \"%s\" failed", of.failed, value->data); |
631 | 1559 } |
1560 | |
1561 switch (code->op) { | |
671 | 1562 |
631 | 1563 case ngx_http_script_file_plain: |
669 | 1564 case ngx_http_script_file_dir: |
1565 case ngx_http_script_file_exists: | |
1566 case ngx_http_script_file_exec: | |
2133
c505e2712e13
fix conflicting names "true" and "false"
Igor Sysoev <igor@sysoev.ru>
parents:
2129
diff
changeset
|
1567 goto false_value; |
671 | 1568 |
631 | 1569 case ngx_http_script_file_not_plain: |
669 | 1570 case ngx_http_script_file_not_dir: |
671 | 1571 case ngx_http_script_file_not_exists: |
669 | 1572 case ngx_http_script_file_not_exec: |
2133
c505e2712e13
fix conflicting names "true" and "false"
Igor Sysoev <igor@sysoev.ru>
parents:
2129
diff
changeset
|
1573 goto true_value; |
631 | 1574 } |
1575 | |
2133
c505e2712e13
fix conflicting names "true" and "false"
Igor Sysoev <igor@sysoev.ru>
parents:
2129
diff
changeset
|
1576 goto false_value; |
631 | 1577 } |
1578 | |
1579 switch (code->op) { | |
1580 case ngx_http_script_file_plain: | |
1454 | 1581 if (of.is_file) { |
2133
c505e2712e13
fix conflicting names "true" and "false"
Igor Sysoev <igor@sysoev.ru>
parents:
2129
diff
changeset
|
1582 goto true_value; |
631 | 1583 } |
2133
c505e2712e13
fix conflicting names "true" and "false"
Igor Sysoev <igor@sysoev.ru>
parents:
2129
diff
changeset
|
1584 goto false_value; |
631 | 1585 |
1586 case ngx_http_script_file_not_plain: | |
1454 | 1587 if (of.is_file) { |
2133
c505e2712e13
fix conflicting names "true" and "false"
Igor Sysoev <igor@sysoev.ru>
parents:
2129
diff
changeset
|
1588 goto false_value; |
631 | 1589 } |
2133
c505e2712e13
fix conflicting names "true" and "false"
Igor Sysoev <igor@sysoev.ru>
parents:
2129
diff
changeset
|
1590 goto true_value; |
669 | 1591 |
1592 case ngx_http_script_file_dir: | |
1454 | 1593 if (of.is_dir) { |
2133
c505e2712e13
fix conflicting names "true" and "false"
Igor Sysoev <igor@sysoev.ru>
parents:
2129
diff
changeset
|
1594 goto true_value; |
669 | 1595 } |
2133
c505e2712e13
fix conflicting names "true" and "false"
Igor Sysoev <igor@sysoev.ru>
parents:
2129
diff
changeset
|
1596 goto false_value; |
669 | 1597 |
1598 case ngx_http_script_file_not_dir: | |
1454 | 1599 if (of.is_dir) { |
2133
c505e2712e13
fix conflicting names "true" and "false"
Igor Sysoev <igor@sysoev.ru>
parents:
2129
diff
changeset
|
1600 goto false_value; |
669 | 1601 } |
2133
c505e2712e13
fix conflicting names "true" and "false"
Igor Sysoev <igor@sysoev.ru>
parents:
2129
diff
changeset
|
1602 goto true_value; |
669 | 1603 |
1604 case ngx_http_script_file_exists: | |
1454 | 1605 if (of.is_file || of.is_dir || of.is_link) { |
2133
c505e2712e13
fix conflicting names "true" and "false"
Igor Sysoev <igor@sysoev.ru>
parents:
2129
diff
changeset
|
1606 goto true_value; |
669 | 1607 } |
2133
c505e2712e13
fix conflicting names "true" and "false"
Igor Sysoev <igor@sysoev.ru>
parents:
2129
diff
changeset
|
1608 goto false_value; |
669 | 1609 |
1610 case ngx_http_script_file_not_exists: | |
1454 | 1611 if (of.is_file || of.is_dir || of.is_link) { |
2133
c505e2712e13
fix conflicting names "true" and "false"
Igor Sysoev <igor@sysoev.ru>
parents:
2129
diff
changeset
|
1612 goto false_value; |
669 | 1613 } |
2133
c505e2712e13
fix conflicting names "true" and "false"
Igor Sysoev <igor@sysoev.ru>
parents:
2129
diff
changeset
|
1614 goto true_value; |
669 | 1615 |
1616 case ngx_http_script_file_exec: | |
1454 | 1617 if (of.is_exec) { |
2133
c505e2712e13
fix conflicting names "true" and "false"
Igor Sysoev <igor@sysoev.ru>
parents:
2129
diff
changeset
|
1618 goto true_value; |
669 | 1619 } |
2133
c505e2712e13
fix conflicting names "true" and "false"
Igor Sysoev <igor@sysoev.ru>
parents:
2129
diff
changeset
|
1620 goto false_value; |
669 | 1621 |
1622 case ngx_http_script_file_not_exec: | |
1454 | 1623 if (of.is_exec) { |
2133
c505e2712e13
fix conflicting names "true" and "false"
Igor Sysoev <igor@sysoev.ru>
parents:
2129
diff
changeset
|
1624 goto false_value; |
669 | 1625 } |
2133
c505e2712e13
fix conflicting names "true" and "false"
Igor Sysoev <igor@sysoev.ru>
parents:
2129
diff
changeset
|
1626 goto true_value; |
631 | 1627 } |
1628 | |
2133
c505e2712e13
fix conflicting names "true" and "false"
Igor Sysoev <igor@sysoev.ru>
parents:
2129
diff
changeset
|
1629 false_value: |
631 | 1630 |
1454 | 1631 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
631 | 1632 "http script file op false"); |
1633 | |
1634 *value = ngx_http_variable_null_value; | |
1635 return; | |
1636 | |
2133
c505e2712e13
fix conflicting names "true" and "false"
Igor Sysoev <igor@sysoev.ru>
parents:
2129
diff
changeset
|
1637 true_value: |
631 | 1638 |
1639 *value = ngx_http_variable_true_value; | |
1640 return; | |
1641 } | |
1642 | |
1643 | |
1644 void | |
515 | 1645 ngx_http_script_complex_value_code(ngx_http_script_engine_t *e) |
1646 { | |
1647 size_t len; | |
1648 ngx_http_script_engine_t le; | |
1649 ngx_http_script_len_code_pt lcode; | |
1650 ngx_http_script_complex_value_code_t *code; | |
1651 | |
1652 code = (ngx_http_script_complex_value_code_t *) e->ip; | |
1653 | |
1654 e->ip += sizeof(ngx_http_script_complex_value_code_t); | |
1655 | |
1656 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0, | |
1657 "http script complex value"); | |
1658 | |
1659 ngx_memzero(&le, sizeof(ngx_http_script_engine_t)); | |
1660 | |
1661 le.ip = code->lengths->elts; | |
655 | 1662 le.line = e->line; |
515 | 1663 le.request = e->request; |
655 | 1664 le.quote = e->quote; |
515 | 1665 |
1666 for (len = 0; *(uintptr_t *) le.ip; len += lcode(&le)) { | |
1667 lcode = *(ngx_http_script_len_code_pt *) le.ip; | |
1668 } | |
1669 | |
1670 e->buf.len = len; | |
2049 | 1671 e->buf.data = ngx_pnalloc(e->request->pool, len); |
515 | 1672 if (e->buf.data == NULL) { |
1673 e->ip = ngx_http_script_exit; | |
1674 e->status = NGX_HTTP_INTERNAL_SERVER_ERROR; | |
1675 return; | |
1676 } | |
1677 | |
1678 e->pos = e->buf.data; | |
1679 | |
577 | 1680 e->sp->len = e->buf.len; |
573 | 1681 e->sp->data = e->buf.data; |
515 | 1682 e->sp++; |
1683 } | |
1684 | |
1685 | |
1686 void | |
509 | 1687 ngx_http_script_value_code(ngx_http_script_engine_t *e) |
1688 { | |
1689 ngx_http_script_value_code_t *code; | |
1690 | |
1691 code = (ngx_http_script_value_code_t *) e->ip; | |
1692 | |
1693 e->ip += sizeof(ngx_http_script_value_code_t); | |
1694 | |
573 | 1695 e->sp->len = code->text_len; |
1696 e->sp->data = (u_char *) code->text_data; | |
577 | 1697 |
1698 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0, | |
1561 | 1699 "http script value: \"%v\"", e->sp); |
577 | 1700 |
509 | 1701 e->sp++; |
1702 } | |
1703 | |
1704 | |
1705 void | |
1706 ngx_http_script_set_var_code(ngx_http_script_engine_t *e) | |
1707 { | |
1708 ngx_http_request_t *r; | |
1709 ngx_http_script_var_code_t *code; | |
1710 | |
1711 code = (ngx_http_script_var_code_t *) e->ip; | |
1712 | |
1713 e->ip += sizeof(ngx_http_script_var_code_t); | |
1714 | |
1715 r = e->request; | |
1716 | |
1717 e->sp--; | |
1718 | |
573 | 1719 r->variables[code->index].len = e->sp->len; |
1720 r->variables[code->index].valid = 1; | |
1565 | 1721 r->variables[code->index].no_cacheable = 0; |
573 | 1722 r->variables[code->index].not_found = 0; |
1723 r->variables[code->index].data = e->sp->data; | |
2393 | 1724 |
1725 #if (NGX_DEBUG) | |
1726 { | |
1727 ngx_http_variable_t *v; | |
1728 ngx_http_core_main_conf_t *cmcf; | |
1729 | |
1730 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); | |
1731 | |
1732 v = cmcf->variables.elts; | |
1733 | |
1734 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0, | |
1735 "http script set $%V", &v[code->index].name); | |
1736 } | |
1737 #endif | |
509 | 1738 } |
1739 | |
1740 | |
1741 void | |
637 | 1742 ngx_http_script_var_set_handler_code(ngx_http_script_engine_t *e) |
1743 { | |
1744 ngx_http_script_var_handler_code_t *code; | |
1745 | |
1746 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0, | |
1747 "http script set var handler"); | |
1748 | |
1749 code = (ngx_http_script_var_handler_code_t *) e->ip; | |
1750 | |
1751 e->ip += sizeof(ngx_http_script_var_handler_code_t); | |
1752 | |
1753 e->sp--; | |
1754 | |
1755 code->handler(e->request, e->sp, code->data); | |
1756 } | |
1757 | |
1758 | |
1759 void | |
509 | 1760 ngx_http_script_var_code(ngx_http_script_engine_t *e) |
1761 { | |
1762 ngx_http_variable_value_t *value; | |
1763 ngx_http_script_var_code_t *code; | |
1764 | |
1765 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0, | |
1766 "http script var"); | |
1767 | |
1768 code = (ngx_http_script_var_code_t *) e->ip; | |
1769 | |
1770 e->ip += sizeof(ngx_http_script_var_code_t); | |
1771 | |
573 | 1772 value = ngx_http_get_flushed_variable(e->request, code->index); |
509 | 1773 |
573 | 1774 if (value && !value->not_found) { |
1775 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0, | |
1406
03341711f9a2
use %v for ngx_variable_value_t in ngx_sprintf(),
Igor Sysoev <igor@sysoev.ru>
parents:
1152
diff
changeset
|
1776 "http script var: \"%v\"", value); |
573 | 1777 |
553 | 1778 *e->sp = *value; |
509 | 1779 e->sp++; |
1780 | |
1781 return; | |
1782 } | |
1783 | |
577 | 1784 *e->sp = ngx_http_variable_null_value; |
509 | 1785 e->sp++; |
1786 } | |
1787 | |
1788 | |
1789 void | |
1790 ngx_http_script_nop_code(ngx_http_script_engine_t *e) | |
1791 { | |
1792 e->ip += sizeof(uintptr_t); | |
1793 } |