Mercurial > hg > nginx-quic
annotate src/http/modules/ngx_http_ssi_filter_module.c @ 1822:935427c55e04
test URI/Destination collection/non-collection and Depth
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Thu, 03 Jan 2008 20:09:51 +0000 |
parents | e584e946e198 |
children | 685048830623 |
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:
290
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:
290
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 |
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:
290
diff
changeset
|
4 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
5 |
14
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
6 |
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 #include <ngx_config.h> |
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_core.h> |
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 #include <ngx_http.h> |
125
885ffb8cc32a
nginx-0.0.1-2003-08-06-09:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
16
diff
changeset
|
10 |
553 | 11 #define NGX_HTTP_SSI_ERROR 1 |
12 | |
13 #define NGX_HTTP_SSI_DATE_LEN 2048 | |
14 | |
15 #define NGX_HTTP_SSI_ADD_PREFIX 1 | |
629 | 16 #define NGX_HTTP_SSI_ADD_ZERO 2 |
635 | 17 #define NGX_HTTP_SSI_EXPR_TEST 4 |
509 | 18 |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
19 |
125
885ffb8cc32a
nginx-0.0.1-2003-08-06-09:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
16
diff
changeset
|
20 typedef struct { |
597 | 21 ngx_flag_t enable; |
22 ngx_flag_t silent_errors; | |
23 ngx_flag_t ignore_recycled_buffers; | |
24 | |
25 ngx_array_t *types; /* array of ngx_str_t */ | |
26 | |
27 size_t min_file_chunk; | |
28 size_t value_len; | |
29 } ngx_http_ssi_loc_conf_t; | |
553 | 30 |
31 | |
32 typedef struct { | |
597 | 33 ngx_str_t name; |
611 | 34 ngx_uint_t key; |
597 | 35 ngx_str_t value; |
36 } ngx_http_ssi_var_t; | |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
37 |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
38 |
667 | 39 typedef struct { |
40 ngx_str_t name; | |
41 ngx_chain_t *bufs; | |
42 ngx_uint_t count; | |
43 } ngx_http_ssi_block_t; | |
44 | |
45 | |
241
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
46 typedef enum { |
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
47 ssi_start_state = 0, |
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
48 ssi_tag_state, |
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
49 ssi_comment0_state, |
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
50 ssi_comment1_state, |
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
51 ssi_sharp_state, |
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
52 ssi_precommand_state, |
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
53 ssi_command_state, |
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
54 ssi_preparam_state, |
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
55 ssi_param_state, |
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
56 ssi_preequal_state, |
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
57 ssi_prevalue_state, |
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
58 ssi_double_quoted_value_state, |
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
59 ssi_quoted_value_state, |
497 | 60 ssi_quoted_symbol_state, |
61 ssi_postparam_state, | |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
62 ssi_comment_end0_state, |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
63 ssi_comment_end1_state, |
241
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
64 ssi_error_state, |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
65 ssi_error_end0_state, |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
66 ssi_error_end1_state |
241
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
67 } ngx_http_ssi_state_e; |
14
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
68 |
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
69 |
509 | 70 static ngx_int_t ngx_http_ssi_output(ngx_http_request_t *r, |
71 ngx_http_ssi_ctx_t *ctx); | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
72 static ngx_int_t ngx_http_ssi_parse(ngx_http_request_t *r, |
497 | 73 ngx_http_ssi_ctx_t *ctx); |
553 | 74 static ngx_str_t *ngx_http_ssi_get_variable(ngx_http_request_t *r, |
611 | 75 ngx_str_t *name, ngx_uint_t key); |
553 | 76 static ngx_int_t ngx_http_ssi_evaluate_string(ngx_http_request_t *r, |
77 ngx_http_ssi_ctx_t *ctx, ngx_str_t *text, ngx_uint_t flags); | |
78 | |
79 static ngx_int_t ngx_http_ssi_include(ngx_http_request_t *r, | |
80 ngx_http_ssi_ctx_t *ctx, ngx_str_t **params); | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
81 static ngx_int_t ngx_http_ssi_stub_output(ngx_http_request_t *r, void *data, |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
82 ngx_int_t rc); |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
83 static ngx_int_t ngx_http_ssi_set_variable(ngx_http_request_t *r, void *data, |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
84 ngx_int_t rc); |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
85 static ngx_int_t ngx_http_ssi_echo(ngx_http_request_t *r, |
497 | 86 ngx_http_ssi_ctx_t *ctx, ngx_str_t **params); |
509 | 87 static ngx_int_t ngx_http_ssi_config(ngx_http_request_t *r, |
88 ngx_http_ssi_ctx_t *ctx, ngx_str_t **params); | |
553 | 89 static ngx_int_t ngx_http_ssi_set(ngx_http_request_t *r, |
509 | 90 ngx_http_ssi_ctx_t *ctx, ngx_str_t **params); |
91 static ngx_int_t ngx_http_ssi_if(ngx_http_request_t *r, | |
92 ngx_http_ssi_ctx_t *ctx, ngx_str_t **params); | |
93 static ngx_int_t ngx_http_ssi_else(ngx_http_request_t *r, | |
94 ngx_http_ssi_ctx_t *ctx, ngx_str_t **params); | |
95 static ngx_int_t ngx_http_ssi_endif(ngx_http_request_t *r, | |
96 ngx_http_ssi_ctx_t *ctx, ngx_str_t **params); | |
667 | 97 static ngx_int_t ngx_http_ssi_block(ngx_http_request_t *r, |
98 ngx_http_ssi_ctx_t *ctx, ngx_str_t **params); | |
99 static ngx_int_t ngx_http_ssi_endblock(ngx_http_request_t *r, | |
100 ngx_http_ssi_ctx_t *ctx, ngx_str_t **params); | |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
101 |
573 | 102 static ngx_int_t ngx_http_ssi_date_gmt_local_variable(ngx_http_request_t *r, |
103 ngx_http_variable_value_t *v, uintptr_t gmt); | |
509 | 104 |
527 | 105 static char *ngx_http_ssi_types(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); |
106 | |
597 | 107 static ngx_int_t ngx_http_ssi_preconfiguration(ngx_conf_t *cf); |
108 static void *ngx_http_ssi_create_main_conf(ngx_conf_t *cf); | |
109 static char *ngx_http_ssi_init_main_conf(ngx_conf_t *cf, void *conf); | |
1169 | 110 static void *ngx_http_ssi_create_loc_conf(ngx_conf_t *cf); |
111 static char *ngx_http_ssi_merge_loc_conf(ngx_conf_t *cf, | |
497 | 112 void *parent, void *child); |
681 | 113 static ngx_int_t ngx_http_ssi_filter_init(ngx_conf_t *cf); |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
114 |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
115 |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
116 static ngx_command_t ngx_http_ssi_filter_commands[] = { |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
117 |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
118 { ngx_string("ssi"), |
681 | 119 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF |
120 |NGX_CONF_FLAG, | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
121 ngx_conf_set_flag_slot, |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
122 NGX_HTTP_LOC_CONF_OFFSET, |
597 | 123 offsetof(ngx_http_ssi_loc_conf_t, enable), |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
124 NULL }, |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
125 |
497 | 126 { ngx_string("ssi_silent_errors"), |
127 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
128 ngx_conf_set_flag_slot, | |
129 NGX_HTTP_LOC_CONF_OFFSET, | |
597 | 130 offsetof(ngx_http_ssi_loc_conf_t, silent_errors), |
497 | 131 NULL }, |
132 | |
509 | 133 { ngx_string("ssi_ignore_recycled_buffers"), |
134 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
135 ngx_conf_set_flag_slot, | |
136 NGX_HTTP_LOC_CONF_OFFSET, | |
597 | 137 offsetof(ngx_http_ssi_loc_conf_t, ignore_recycled_buffers), |
509 | 138 NULL }, |
139 | |
497 | 140 { ngx_string("ssi_min_file_chunk"), |
141 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
142 ngx_conf_set_size_slot, | |
143 NGX_HTTP_LOC_CONF_OFFSET, | |
597 | 144 offsetof(ngx_http_ssi_loc_conf_t, min_file_chunk), |
497 | 145 NULL }, |
146 | |
589 | 147 { ngx_string("ssi_value_length"), |
148 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
149 ngx_conf_set_size_slot, | |
150 NGX_HTTP_LOC_CONF_OFFSET, | |
597 | 151 offsetof(ngx_http_ssi_loc_conf_t, value_len), |
589 | 152 NULL }, |
153 | |
527 | 154 { ngx_string("ssi_types"), |
155 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, | |
156 ngx_http_ssi_types, | |
157 NGX_HTTP_LOC_CONF_OFFSET, | |
158 0, | |
159 NULL }, | |
160 | |
497 | 161 ngx_null_command |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
162 }; |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
163 |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
164 |
577 | 165 |
125
885ffb8cc32a
nginx-0.0.1-2003-08-06-09:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
16
diff
changeset
|
166 static ngx_http_module_t ngx_http_ssi_filter_module_ctx = { |
597 | 167 ngx_http_ssi_preconfiguration, /* preconfiguration */ |
681 | 168 ngx_http_ssi_filter_init, /* postconfiguration */ |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
169 |
597 | 170 ngx_http_ssi_create_main_conf, /* create main configuration */ |
171 ngx_http_ssi_init_main_conf, /* init main configuration */ | |
14
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
172 |
125
885ffb8cc32a
nginx-0.0.1-2003-08-06-09:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
16
diff
changeset
|
173 NULL, /* create server configuration */ |
885ffb8cc32a
nginx-0.0.1-2003-08-06-09:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
16
diff
changeset
|
174 NULL, /* merge server configuration */ |
885ffb8cc32a
nginx-0.0.1-2003-08-06-09:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
16
diff
changeset
|
175 |
1169 | 176 ngx_http_ssi_create_loc_conf, /* create location configuration */ |
177 ngx_http_ssi_merge_loc_conf /* merge location configuration */ | |
577 | 178 }; |
14
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
179 |
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
180 |
125
885ffb8cc32a
nginx-0.0.1-2003-08-06-09:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
16
diff
changeset
|
181 ngx_module_t ngx_http_ssi_filter_module = { |
509 | 182 NGX_MODULE_V1, |
125
885ffb8cc32a
nginx-0.0.1-2003-08-06-09:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
16
diff
changeset
|
183 &ngx_http_ssi_filter_module_ctx, /* module context */ |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
184 ngx_http_ssi_filter_commands, /* module directives */ |
125
885ffb8cc32a
nginx-0.0.1-2003-08-06-09:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
16
diff
changeset
|
185 NGX_HTTP_MODULE, /* module type */ |
541 | 186 NULL, /* init master */ |
681 | 187 NULL, /* init module */ |
541 | 188 NULL, /* init process */ |
189 NULL, /* init thread */ | |
190 NULL, /* exit thread */ | |
191 NULL, /* exit process */ | |
192 NULL, /* exit master */ | |
193 NGX_MODULE_V1_PADDING | |
14
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
194 }; |
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
195 |
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
196 |
569 | 197 static ngx_http_output_header_filter_pt ngx_http_next_header_filter; |
198 static ngx_http_output_body_filter_pt ngx_http_next_body_filter; | |
497 | 199 |
200 | |
201 static u_char ngx_http_ssi_string[] = "<!--"; | |
202 | |
203 static ngx_str_t ngx_http_ssi_none = ngx_string("(none)"); | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
204 static ngx_str_t ngx_http_ssi_null_string = ngx_null_string; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
205 |
16
6ce4755737b4
nginx-0.0.1-2002-09-26-20:50:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
15
diff
changeset
|
206 |
553 | 207 #define NGX_HTTP_SSI_INCLUDE_VIRTUAL 0 |
208 #define NGX_HTTP_SSI_INCLUDE_FILE 1 | |
645 | 209 #define NGX_HTTP_SSI_INCLUDE_WAIT 2 |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
210 #define NGX_HTTP_SSI_INCLUDE_SET 3 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
211 #define NGX_HTTP_SSI_INCLUDE_STUB 4 |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
212 |
509 | 213 #define NGX_HTTP_SSI_ECHO_VAR 0 |
214 #define NGX_HTTP_SSI_ECHO_DEFAULT 1 | |
1545 | 215 #define NGX_HTTP_SSI_ECHO_ENCODING 2 |
509 | 216 |
547 | 217 #define NGX_HTTP_SSI_CONFIG_ERRMSG 0 |
218 #define NGX_HTTP_SSI_CONFIG_TIMEFMT 1 | |
509 | 219 |
553 | 220 #define NGX_HTTP_SSI_SET_VAR 0 |
221 #define NGX_HTTP_SSI_SET_VALUE 1 | |
509 | 222 |
223 #define NGX_HTTP_SSI_IF_EXPR 0 | |
224 | |
667 | 225 #define NGX_HTTP_SSI_BLOCK_NAME 0 |
226 | |
497 | 227 |
553 | 228 static ngx_http_ssi_param_t ngx_http_ssi_include_params[] = { |
597 | 229 { ngx_string("virtual"), NGX_HTTP_SSI_INCLUDE_VIRTUAL, 0, 0 }, |
230 { ngx_string("file"), NGX_HTTP_SSI_INCLUDE_FILE, 0, 0 }, | |
645 | 231 { ngx_string("wait"), NGX_HTTP_SSI_INCLUDE_WAIT, 0, 0 }, |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
232 { ngx_string("set"), NGX_HTTP_SSI_INCLUDE_SET, 0, 0 }, |
667 | 233 { ngx_string("stub"), NGX_HTTP_SSI_INCLUDE_STUB, 0, 0 }, |
597 | 234 { ngx_null_string, 0, 0, 0 } |
553 | 235 }; |
236 | |
237 | |
497 | 238 static ngx_http_ssi_param_t ngx_http_ssi_echo_params[] = { |
597 | 239 { ngx_string("var"), NGX_HTTP_SSI_ECHO_VAR, 1, 0 }, |
240 { ngx_string("default"), NGX_HTTP_SSI_ECHO_DEFAULT, 0, 0 }, | |
1545 | 241 { ngx_string("encoding"), NGX_HTTP_SSI_ECHO_ENCODING, 0, 0 }, |
597 | 242 { ngx_null_string, 0, 0, 0 } |
497 | 243 }; |
127
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
244 |
509 | 245 |
246 static ngx_http_ssi_param_t ngx_http_ssi_config_params[] = { | |
597 | 247 { ngx_string("errmsg"), NGX_HTTP_SSI_CONFIG_ERRMSG, 0, 0 }, |
248 { ngx_string("timefmt"), NGX_HTTP_SSI_CONFIG_TIMEFMT, 0, 0 }, | |
249 { ngx_null_string, 0, 0, 0 } | |
509 | 250 }; |
251 | |
252 | |
553 | 253 static ngx_http_ssi_param_t ngx_http_ssi_set_params[] = { |
597 | 254 { ngx_string("var"), NGX_HTTP_SSI_SET_VAR, 1, 0 }, |
255 { ngx_string("value"), NGX_HTTP_SSI_SET_VALUE, 1, 0 }, | |
256 { ngx_null_string, 0, 0, 0 } | |
553 | 257 }; |
258 | |
259 | |
509 | 260 static ngx_http_ssi_param_t ngx_http_ssi_if_params[] = { |
597 | 261 { ngx_string("expr"), NGX_HTTP_SSI_IF_EXPR, 1, 0 }, |
262 { ngx_null_string, 0, 0, 0 } | |
509 | 263 }; |
264 | |
265 | |
667 | 266 static ngx_http_ssi_param_t ngx_http_ssi_block_params[] = { |
267 { ngx_string("name"), NGX_HTTP_SSI_BLOCK_NAME, 1, 0 }, | |
268 { ngx_null_string, 0, 0, 0 } | |
269 }; | |
270 | |
271 | |
509 | 272 static ngx_http_ssi_param_t ngx_http_ssi_no_params[] = { |
597 | 273 { ngx_null_string, 0, 0, 0 } |
509 | 274 }; |
275 | |
127
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
276 |
497 | 277 static ngx_http_ssi_command_t ngx_http_ssi_commands[] = { |
553 | 278 { ngx_string("include"), ngx_http_ssi_include, |
667 | 279 ngx_http_ssi_include_params, 0, 0, 1 }, |
280 { ngx_string("echo"), ngx_http_ssi_echo, | |
281 ngx_http_ssi_echo_params, 0, 0, 0 }, | |
509 | 282 { ngx_string("config"), ngx_http_ssi_config, |
667 | 283 ngx_http_ssi_config_params, 0, 0, 0 }, |
284 { ngx_string("set"), ngx_http_ssi_set, ngx_http_ssi_set_params, 0, 0, 0 }, | |
285 | |
286 { ngx_string("if"), ngx_http_ssi_if, ngx_http_ssi_if_params, 0, 0, 0 }, | |
629 | 287 { ngx_string("elif"), ngx_http_ssi_if, ngx_http_ssi_if_params, |
667 | 288 NGX_HTTP_SSI_COND_IF, 0, 0 }, |
629 | 289 { ngx_string("else"), ngx_http_ssi_else, ngx_http_ssi_no_params, |
667 | 290 NGX_HTTP_SSI_COND_IF, 0, 0 }, |
629 | 291 { ngx_string("endif"), ngx_http_ssi_endif, ngx_http_ssi_no_params, |
667 | 292 NGX_HTTP_SSI_COND_ELSE, 0, 0 }, |
293 | |
294 { ngx_string("block"), ngx_http_ssi_block, | |
295 ngx_http_ssi_block_params, 0, 0, 0 }, | |
296 { ngx_string("endblock"), ngx_http_ssi_endblock, | |
297 ngx_http_ssi_no_params, 0, 1, 0 }, | |
298 | |
299 { ngx_null_string, NULL, NULL, 0, 0, 0 } | |
497 | 300 }; |
301 | |
302 | |
509 | 303 static ngx_http_variable_t ngx_http_ssi_vars[] = { |
304 | |
637 | 305 { ngx_string("date_local"), NULL, ngx_http_ssi_date_gmt_local_variable, 0, |
1565 | 306 NGX_HTTP_VAR_NOCACHEABLE, 0 }, |
509 | 307 |
637 | 308 { ngx_string("date_gmt"), NULL, ngx_http_ssi_date_gmt_local_variable, 1, |
1565 | 309 NGX_HTTP_VAR_NOCACHEABLE, 0 }, |
509 | 310 |
637 | 311 { ngx_null_string, NULL, NULL, 0, 0, 0 } |
509 | 312 }; |
313 | |
314 | |
315 | |
497 | 316 static ngx_int_t |
317 ngx_http_ssi_header_filter(ngx_http_request_t *r) | |
129
7a886b9a67dc
nginx-0.0.1-2003-08-10-20:14:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
318 { |
597 | 319 ngx_uint_t i; |
320 ngx_str_t *type; | |
321 ngx_http_ssi_ctx_t *ctx; | |
322 ngx_http_ssi_loc_conf_t *slcf; | |
323 | |
324 slcf = ngx_http_get_module_loc_conf(r, ngx_http_ssi_filter_module); | |
325 | |
326 if (!slcf->enable | |
577 | 327 || r->headers_out.content_type.len == 0 |
328 || r->headers_out.content_length_n == 0) | |
247
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
243
diff
changeset
|
329 { |
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
243
diff
changeset
|
330 return ngx_http_next_header_filter(r); |
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
243
diff
changeset
|
331 } |
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
243
diff
changeset
|
332 |
497 | 333 |
597 | 334 type = slcf->types->elts; |
335 for (i = 0; i < slcf->types->nelts; i++) { | |
527 | 336 if (r->headers_out.content_type.len >= type[i].len |
337 && ngx_strncasecmp(r->headers_out.content_type.data, | |
338 type[i].data, type[i].len) == 0) | |
339 { | |
340 goto found; | |
341 } | |
342 } | |
343 | |
344 return ngx_http_next_header_filter(r); | |
345 | |
346 | |
347 found: | |
348 | |
499 | 349 ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_ssi_ctx_t)); |
350 if (ctx == NULL) { | |
497 | 351 return NGX_ERROR; |
352 } | |
353 | |
354 ngx_http_set_ctx(r, ctx, ngx_http_ssi_filter_module); | |
355 | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
356 |
597 | 357 ctx->value_len = slcf->value_len; |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
358 ctx->last_out = &ctx->out; |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
359 |
1545 | 360 ctx->encoding = NGX_HTTP_SSI_ENTITY_ENCODING; |
509 | 361 ctx->output = 1; |
362 | |
497 | 363 ctx->params.elts = ctx->params_array; |
364 ctx->params.size = sizeof(ngx_table_elt_t); | |
365 ctx->params.nalloc = NGX_HTTP_SSI_PARAMS_N; | |
366 ctx->params.pool = r->pool; | |
367 | |
509 | 368 ctx->timefmt.len = sizeof("%A, %d-%b-%Y %H:%M:%S %Z") - 1; |
369 ctx->timefmt.data = (u_char *) "%A, %d-%b-%Y %H:%M:%S %Z"; | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
370 |
547 | 371 ctx->errmsg.len = |
372 sizeof("[an error occurred while processing the directive]") - 1; | |
373 ctx->errmsg.data = (u_char *) | |
374 "[an error occurred while processing the directive]"; | |
375 | |
497 | 376 r->filter_need_in_memory = 1; |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
377 |
597 | 378 if (r == r->main) { |
577 | 379 ngx_http_clear_content_length(r); |
380 ngx_http_clear_last_modified(r); | |
509 | 381 } |
382 | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
383 return ngx_http_next_header_filter(r); |
129
7a886b9a67dc
nginx-0.0.1-2003-08-10-20:14:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
384 } |
7a886b9a67dc
nginx-0.0.1-2003-08-10-20:14:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
385 |
7a886b9a67dc
nginx-0.0.1-2003-08-10-20:14:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
386 |
497 | 387 static ngx_int_t |
388 ngx_http_ssi_body_filter(ngx_http_request_t *r, ngx_chain_t *in) | |
15
cbb38b60495c
nginx-0.0.1-2002-09-18-20:32:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
14
diff
changeset
|
389 { |
667 | 390 size_t len; |
597 | 391 ngx_int_t rc; |
392 ngx_buf_t *b; | |
393 ngx_uint_t i, index; | |
667 | 394 ngx_chain_t *cl, **ll; |
597 | 395 ngx_table_elt_t *param; |
767
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
396 ngx_http_request_t *pr; |
667 | 397 ngx_http_ssi_ctx_t *ctx, *mctx; |
398 ngx_http_ssi_block_t *bl; | |
597 | 399 ngx_http_ssi_param_t *prm; |
400 ngx_http_ssi_command_t *cmd; | |
401 ngx_http_ssi_loc_conf_t *slcf; | |
402 ngx_http_ssi_main_conf_t *smcf; | |
599 | 403 ngx_str_t *params[NGX_HTTP_SSI_MAX_PARAMS + 1]; |
16
6ce4755737b4
nginx-0.0.1-2002-09-26-20:50:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
15
diff
changeset
|
404 |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
405 ctx = ngx_http_get_module_ctx(r, ngx_http_ssi_filter_module); |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
406 |
645 | 407 if (ctx == NULL |
408 || (in == NULL | |
409 && ctx->buf == NULL | |
410 && ctx->in == NULL | |
411 && ctx->busy == NULL)) | |
412 { | |
243
bf2faf694c19
nginx-0.0.1-2004-01-28-23:38:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
242
diff
changeset
|
413 return ngx_http_next_body_filter(r, in); |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
414 } |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
415 |
497 | 416 /* add the incoming chain to the chain ctx->in */ |
129
7a886b9a67dc
nginx-0.0.1-2003-08-10-20:14:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
417 |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
418 if (in) { |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
419 if (ngx_chain_add_copy(r->pool, &ctx->in, in) == NGX_ERROR) { |
129
7a886b9a67dc
nginx-0.0.1-2003-08-10-20:14:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
420 return NGX_ERROR; |
7a886b9a67dc
nginx-0.0.1-2003-08-10-20:14:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
421 } |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
422 } |
129
7a886b9a67dc
nginx-0.0.1-2003-08-10-20:14:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
423 |
645 | 424 if (ctx->wait) { |
767
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
425 if (r->connection->data != r) { |
645 | 426 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
427 "http ssi filter \"%V\" wait", &r->uri); | |
428 return NGX_AGAIN; | |
429 } | |
430 | |
767
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
431 for (pr = ctx->wait->parent; pr; pr = pr->parent) { |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
432 if (pr == r) { |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
433 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
434 "http ssi filter \"%V\" flush", &r->uri); |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
435 |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
436 rc = ngx_http_next_body_filter(r, NULL); |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
437 |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
438 if (ctx->wait->done) { |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
439 ctx->wait = NULL; |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
440 } |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
441 |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
442 if (rc == NGX_ERROR || rc == NGX_AGAIN) { |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
443 return rc; |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
444 } |
1320 | 445 |
446 break; | |
767
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
447 } |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
448 } |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
449 |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
450 if (ctx->wait == r) { |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
451 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
452 "http ssi filter \"%V\" continue", &r->uri); |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
453 ctx->wait = NULL; |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
454 } |
645 | 455 } |
456 | |
597 | 457 slcf = ngx_http_get_module_loc_conf(r, ngx_http_ssi_filter_module); |
129
7a886b9a67dc
nginx-0.0.1-2003-08-10-20:14:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
458 |
509 | 459 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
460 "http ssi filter \"%V\"", &r->uri); | |
241
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
461 |
499 | 462 while (ctx->in || ctx->buf) { |
241
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
463 |
499 | 464 if (ctx->buf == NULL ){ |
465 ctx->buf = ctx->in->buf; | |
466 ctx->in = ctx->in->next; | |
467 ctx->pos = ctx->buf->pos; | |
468 } | |
497 | 469 |
470 if (ctx->state == ssi_start_state) { | |
471 ctx->copy_start = ctx->pos; | |
472 ctx->copy_end = ctx->pos; | |
129
7a886b9a67dc
nginx-0.0.1-2003-08-10-20:14:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
473 } |
7a886b9a67dc
nginx-0.0.1-2003-08-10-20:14:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
474 |
499 | 475 b = NULL; |
476 | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
477 while (ctx->pos < ctx->buf->last) { |
241
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
478 |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
479 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
480 "saved: %d state: %d", ctx->saved, ctx->state); |
241
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
481 |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
482 rc = ngx_http_ssi_parse(r, ctx); |
129
7a886b9a67dc
nginx-0.0.1-2003-08-10-20:14:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
483 |
497 | 484 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
485 "parse: %d, looked: %d %p-%p", | |
486 rc, ctx->looked, ctx->copy_start, ctx->copy_end); | |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
487 |
497 | 488 if (rc == NGX_ERROR) { |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
489 return rc; |
497 | 490 } |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
491 |
497 | 492 if (ctx->copy_start != ctx->copy_end) { |
241
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
493 |
509 | 494 if (ctx->output) { |
495 | |
496 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
497 "saved: %d", ctx->saved); | |
498 | |
499 if (ctx->saved) { | |
500 | |
501 if (ctx->free) { | |
502 cl = ctx->free; | |
503 ctx->free = ctx->free->next; | |
504 b = cl->buf; | |
505 ngx_memzero(b, sizeof(ngx_buf_t)); | |
241
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
506 |
509 | 507 } else { |
508 b = ngx_calloc_buf(r->pool); | |
509 if (b == NULL) { | |
510 return NGX_ERROR; | |
511 } | |
512 | |
513 cl = ngx_alloc_chain_link(r->pool); | |
514 if (cl == NULL) { | |
515 return NGX_ERROR; | |
516 } | |
517 | |
518 cl->buf = b; | |
519 } | |
520 | |
521 b->memory = 1; | |
522 b->pos = ngx_http_ssi_string; | |
523 b->last = ngx_http_ssi_string + ctx->saved; | |
524 | |
525 *ctx->last_out = cl; | |
526 ctx->last_out = &cl->next; | |
527 | |
528 ctx->saved = 0; | |
529 } | |
499 | 530 |
531 if (ctx->free) { | |
532 cl = ctx->free; | |
533 ctx->free = ctx->free->next; | |
534 b = cl->buf; | |
535 | |
536 } else { | |
509 | 537 b = ngx_alloc_buf(r->pool); |
499 | 538 if (b == NULL) { |
539 return NGX_ERROR; | |
540 } | |
541 | |
542 cl = ngx_alloc_chain_link(r->pool); | |
543 if (cl == NULL) { | |
544 return NGX_ERROR; | |
545 } | |
546 | |
547 cl->buf = b; | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
548 } |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
549 |
509 | 550 ngx_memcpy(b, ctx->buf, sizeof(ngx_buf_t)); |
551 | |
513 | 552 b->pos = ctx->copy_start; |
553 b->last = ctx->copy_end; | |
554 b->shadow = NULL; | |
509 | 555 b->last_buf = 0; |
556 b->recycled = 0; | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
557 |
509 | 558 if (b->in_file) { |
597 | 559 if (slcf->min_file_chunk < (size_t) (b->last - b->pos)) |
509 | 560 { |
561 b->file_last = b->file_pos + (b->last - b->start); | |
562 b->file_pos += b->pos - b->start; | |
563 | |
564 } else { | |
565 b->in_file = 0; | |
566 } | |
567 } | |
568 | |
569 cl->next = NULL; | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
570 *ctx->last_out = cl; |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
571 ctx->last_out = &cl->next; |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
572 |
509 | 573 } else { |
667 | 574 if (ctx->block |
575 && ctx->saved + (ctx->copy_end - ctx->copy_start)) | |
576 { | |
577 b = ngx_create_temp_buf(r->pool, | |
578 ctx->saved + (ctx->copy_end - ctx->copy_start)); | |
579 | |
580 if (b == NULL) { | |
581 return NGX_ERROR; | |
582 } | |
583 | |
584 if (ctx->saved) { | |
585 b->last = ngx_cpymem(b->pos, ngx_http_ssi_string, | |
586 ctx->saved); | |
587 } | |
588 | |
589 b->last = ngx_cpymem(b->last, ctx->copy_start, | |
590 ctx->copy_end - ctx->copy_start); | |
591 | |
592 cl = ngx_alloc_chain_link(r->pool); | |
593 if (cl == NULL) { | |
594 return NGX_ERROR; | |
595 } | |
596 | |
597 cl->buf = b; | |
598 cl->next = NULL; | |
599 | |
600 b = NULL; | |
601 | |
602 mctx = ngx_http_get_module_ctx(r->main, | |
603 ngx_http_ssi_filter_module); | |
604 bl = mctx->blocks->elts; | |
605 for (ll = &bl[mctx->blocks->nelts - 1].bufs; | |
606 *ll; | |
607 ll = &(*ll)->next) | |
608 { | |
609 /* void */ | |
610 } | |
611 | |
612 *ll = cl; | |
613 } | |
614 | |
241
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
615 ctx->saved = 0; |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
616 } |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
617 } |
497 | 618 |
619 if (ctx->state == ssi_start_state) { | |
620 ctx->copy_start = ctx->pos; | |
621 ctx->copy_end = ctx->pos; | |
240
725129fdd524
nginx-0.0.1-2004-01-26-20:22:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
239
diff
changeset
|
622 |
497 | 623 } else { |
624 ctx->copy_start = NULL; | |
625 ctx->copy_end = NULL; | |
626 } | |
627 | |
628 if (rc == NGX_AGAIN) { | |
629 continue; | |
630 } | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
631 |
497 | 632 |
573 | 633 b = NULL; |
634 | |
497 | 635 if (rc == NGX_OK) { |
636 | |
597 | 637 smcf = ngx_http_get_module_main_conf(r, |
638 ngx_http_ssi_filter_module); | |
639 | |
640 cmd = ngx_hash_find(&smcf->hash, ctx->key, ctx->command.data, | |
641 ctx->command.len); | |
642 | |
643 if (cmd == NULL) { | |
644 if (ctx->output) { | |
645 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
646 "invalid SSI command: \"%V\"", | |
647 &ctx->command); | |
648 goto ssi_error; | |
497 | 649 } |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
650 |
597 | 651 continue; |
497 | 652 } |
653 | |
629 | 654 if (cmd->conditional |
655 && (ctx->conditional == 0 | |
656 || ctx->conditional > cmd->conditional)) | |
657 { | |
658 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
659 "invalid context of SSI command: \"%V\"", | |
660 &ctx->command); | |
661 goto ssi_error; | |
662 } | |
663 | |
667 | 664 if (!ctx->output && !cmd->block) { |
665 | |
666 if (ctx->block) { | |
667 | |
668 /* reconstruct the SSI command text */ | |
669 | |
670 len = 5 + ctx->command.len + 4; | |
671 | |
672 param = ctx->params.elts; | |
673 for (i = 0; i < ctx->params.nelts; i++) { | |
674 len += 1 + param[i].key.len + 2 | |
675 + param[i].value.len + 1; | |
676 } | |
677 | |
678 b = ngx_create_temp_buf(r->pool, len); | |
679 | |
680 if (b == NULL) { | |
681 return NGX_ERROR; | |
682 } | |
683 | |
684 cl = ngx_alloc_chain_link(r->pool); | |
685 if (cl == NULL) { | |
686 return NGX_ERROR; | |
687 } | |
688 | |
689 cl->buf = b; | |
690 cl->next = NULL; | |
691 | |
692 *b->last++ = '<'; | |
693 *b->last++ = '!'; | |
694 *b->last++ = '-'; | |
695 *b->last++ = '-'; | |
696 *b->last++ = '#'; | |
697 | |
698 b->last = ngx_cpymem(b->last, ctx->command.data, | |
699 ctx->command.len); | |
700 | |
701 for (i = 0; i < ctx->params.nelts; i++) { | |
702 *b->last++ = ' '; | |
703 b->last = ngx_cpymem(b->last, param[i].key.data, | |
704 param[i].key.len); | |
705 *b->last++ = '='; | |
706 *b->last++ = '"'; | |
707 b->last = ngx_cpymem(b->last, param[i].value.data, | |
708 param[i].value.len); | |
709 *b->last++ = '"'; | |
710 } | |
711 | |
712 *b->last++ = ' '; | |
713 *b->last++ = '-'; | |
714 *b->last++ = '-'; | |
715 *b->last++ = '>'; | |
716 | |
717 mctx = ngx_http_get_module_ctx(r->main, | |
718 ngx_http_ssi_filter_module); | |
719 bl = mctx->blocks->elts; | |
720 for (ll = &bl[mctx->blocks->nelts - 1].bufs; | |
721 *ll; | |
722 ll = &(*ll)->next) | |
723 { | |
724 /* void */ | |
725 } | |
726 | |
727 *ll = cl; | |
728 | |
729 b = NULL; | |
730 | |
731 continue; | |
732 } | |
733 | |
734 if (cmd->conditional == 0) { | |
735 continue; | |
736 } | |
509 | 737 } |
738 | |
597 | 739 if (ctx->params.nelts > NGX_HTTP_SSI_MAX_PARAMS) { |
740 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
741 "too many SSI command paramters: \"%V\"", | |
742 &ctx->command); | |
743 goto ssi_error; | |
744 } | |
745 | |
497 | 746 ngx_memzero(params, |
599 | 747 (NGX_HTTP_SSI_MAX_PARAMS + 1) * sizeof(ngx_str_t *)); |
497 | 748 |
749 param = ctx->params.elts; | |
750 | |
751 for (i = 0; i < ctx->params.nelts; i++) { | |
752 | |
753 for (prm = cmd->params; prm->name.len; prm++) { | |
754 | |
755 if (param[i].key.len != prm->name.len | |
756 || ngx_strncmp(param[i].key.data, prm->name.data, | |
757 prm->name.len) != 0) | |
758 { | |
759 continue; | |
760 } | |
761 | |
597 | 762 if (!prm->multiple) { |
763 if (params[prm->index]) { | |
764 ngx_log_error(NGX_LOG_ERR, | |
765 r->connection->log, 0, | |
766 "duplicate \"%V\" parameter " | |
767 "in \"%V\" SSI command", | |
768 ¶m[i].key, &ctx->command); | |
769 | |
770 goto ssi_error; | |
771 } | |
772 | |
773 params[prm->index] = ¶m[i].value; | |
774 | |
775 break; | |
497 | 776 } |
777 | |
597 | 778 for (index = prm->index; params[index]; index++) { |
779 /* void */ | |
780 } | |
781 | |
782 params[index] = ¶m[i].value; | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
783 |
497 | 784 break; |
785 } | |
786 | |
787 if (prm->name.len == 0) { | |
788 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
789 "invalid parameter name: \"%V\" " | |
790 "in \"%V\" SSI command", | |
791 ¶m[i].key, &ctx->command); | |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
792 |
497 | 793 goto ssi_error; |
794 } | |
795 } | |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
796 |
497 | 797 for (prm = cmd->params; prm->name.len; prm++) { |
798 if (prm->mandatory && params[prm->index] == 0) { | |
799 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
800 "mandatory \"%V\" parameter is absent " | |
801 "in \"%V\" SSI command", | |
802 &prm->name, &ctx->command); | |
803 | |
804 goto ssi_error; | |
805 } | |
806 } | |
807 | |
1261
58691d40829f
if a subrequest was finished and SSI was in middle of SSI command parsing
Igor Sysoev <igor@sysoev.ru>
parents:
1260
diff
changeset
|
808 if (cmd->flush) { |
58691d40829f
if a subrequest was finished and SSI was in middle of SSI command parsing
Igor Sysoev <igor@sysoev.ru>
parents:
1260
diff
changeset
|
809 |
58691d40829f
if a subrequest was finished and SSI was in middle of SSI command parsing
Igor Sysoev <igor@sysoev.ru>
parents:
1260
diff
changeset
|
810 if (ctx->out) { |
58691d40829f
if a subrequest was finished and SSI was in middle of SSI command parsing
Igor Sysoev <igor@sysoev.ru>
parents:
1260
diff
changeset
|
811 rc = ngx_http_ssi_output(r, ctx); |
58691d40829f
if a subrequest was finished and SSI was in middle of SSI command parsing
Igor Sysoev <igor@sysoev.ru>
parents:
1260
diff
changeset
|
812 |
58691d40829f
if a subrequest was finished and SSI was in middle of SSI command parsing
Igor Sysoev <igor@sysoev.ru>
parents:
1260
diff
changeset
|
813 } else { |
58691d40829f
if a subrequest was finished and SSI was in middle of SSI command parsing
Igor Sysoev <igor@sysoev.ru>
parents:
1260
diff
changeset
|
814 rc = ngx_http_next_body_filter(r, NULL); |
58691d40829f
if a subrequest was finished and SSI was in middle of SSI command parsing
Igor Sysoev <igor@sysoev.ru>
parents:
1260
diff
changeset
|
815 } |
509 | 816 |
817 if (rc == NGX_ERROR) { | |
818 return NGX_ERROR; | |
819 } | |
820 } | |
821 | |
569 | 822 rc = cmd->handler(r, ctx, params); |
823 | |
824 if (rc == NGX_OK) { | |
497 | 825 continue; |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
826 } |
583 | 827 |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
828 if (rc == NGX_DONE || rc == NGX_AGAIN || rc == NGX_ERROR) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
829 return rc; |
583 | 830 } |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
831 } |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
832 |
497 | 833 |
834 /* rc == NGX_HTTP_SSI_ERROR */ | |
835 | |
499 | 836 ssi_error: |
497 | 837 |
597 | 838 if (slcf->silent_errors) { |
497 | 839 continue; |
840 } | |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
841 |
499 | 842 if (ctx->free) { |
843 cl = ctx->free; | |
844 ctx->free = ctx->free->next; | |
845 b = cl->buf; | |
846 ngx_memzero(b, sizeof(ngx_buf_t)); | |
847 | |
848 } else { | |
849 b = ngx_calloc_buf(r->pool); | |
850 if (b == NULL) { | |
851 return NGX_ERROR; | |
852 } | |
853 | |
854 cl = ngx_alloc_chain_link(r->pool); | |
855 if (cl == NULL) { | |
856 return NGX_ERROR; | |
857 } | |
858 | |
859 cl->buf = b; | |
497 | 860 } |
16
6ce4755737b4
nginx-0.0.1-2002-09-26-20:50:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
15
diff
changeset
|
861 |
497 | 862 b->memory = 1; |
547 | 863 b->pos = ctx->errmsg.data; |
864 b->last = ctx->errmsg.data + ctx->errmsg.len; | |
16
6ce4755737b4
nginx-0.0.1-2002-09-26-20:50:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
15
diff
changeset
|
865 |
497 | 866 cl->next = NULL; |
867 *ctx->last_out = cl; | |
868 ctx->last_out = &cl->next; | |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
869 |
497 | 870 continue; |
871 } | |
872 | |
710
6875ee9f93c7
ssi did work with memcached and nonbuffered responses
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
873 if (ctx->buf->last_buf || ngx_buf_in_memory(ctx->buf)) { |
499 | 874 if (b == NULL) { |
875 if (ctx->free) { | |
876 cl = ctx->free; | |
877 ctx->free = ctx->free->next; | |
878 b = cl->buf; | |
879 ngx_memzero(b, sizeof(ngx_buf_t)); | |
880 | |
881 } else { | |
882 b = ngx_calloc_buf(r->pool); | |
883 if (b == NULL) { | |
884 return NGX_ERROR; | |
885 } | |
497 | 886 |
499 | 887 cl = ngx_alloc_chain_link(r->pool); |
888 if (cl == NULL) { | |
889 return NGX_ERROR; | |
890 } | |
891 | |
892 cl->buf = b; | |
893 } | |
894 | |
509 | 895 b->sync = 1; |
896 | |
499 | 897 cl->next = NULL; |
898 *ctx->last_out = cl; | |
899 ctx->last_out = &cl->next; | |
900 } | |
901 | |
902 b->last_buf = ctx->buf->last_buf; | |
903 b->shadow = ctx->buf; | |
509 | 904 |
597 | 905 if (slcf->ignore_recycled_buffers == 0) { |
509 | 906 b->recycled = ctx->buf->recycled; |
907 } | |
497 | 908 } |
909 | |
499 | 910 ctx->buf = NULL; |
911 | |
497 | 912 ctx->saved = ctx->looked; |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
913 } |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
914 |
499 | 915 if (ctx->out == NULL && ctx->busy == NULL) { |
497 | 916 return NGX_OK; |
129
7a886b9a67dc
nginx-0.0.1-2003-08-10-20:14:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
917 } |
7a886b9a67dc
nginx-0.0.1-2003-08-10-20:14:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
918 |
509 | 919 return ngx_http_ssi_output(r, ctx); |
920 } | |
921 | |
922 | |
923 static ngx_int_t | |
924 ngx_http_ssi_output(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx) | |
925 { | |
926 ngx_int_t rc; | |
927 ngx_buf_t *b; | |
928 ngx_chain_t *cl; | |
929 | |
641 | 930 #if 1 |
931 b = NULL; | |
932 for (cl = ctx->out; cl; cl = cl->next) { | |
643 | 933 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
934 "ssi out: %p %p", cl->buf, cl->buf->pos); | |
641 | 935 if (cl->buf == b) { |
936 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, | |
937 "the same buf was used in ssi"); | |
938 ngx_debug_point(); | |
939 return NGX_ERROR; | |
940 } | |
941 b = cl->buf; | |
942 } | |
943 #endif | |
944 | |
497 | 945 rc = ngx_http_next_body_filter(r, ctx->out); |
129
7a886b9a67dc
nginx-0.0.1-2003-08-10-20:14:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
946 |
499 | 947 if (ctx->busy == NULL) { |
948 ctx->busy = ctx->out; | |
949 | |
950 } else { | |
951 for (cl = ctx->busy; cl->next; cl = cl->next) { /* void */ } | |
952 cl->next = ctx->out; | |
953 } | |
954 | |
497 | 955 ctx->out = NULL; |
956 ctx->last_out = &ctx->out; | |
129
7a886b9a67dc
nginx-0.0.1-2003-08-10-20:14:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
957 |
499 | 958 while (ctx->busy) { |
959 | |
657 | 960 cl = ctx->busy; |
961 b = cl->buf; | |
499 | 962 |
963 if (ngx_buf_size(b) != 0) { | |
964 break; | |
965 } | |
966 | |
967 #if (NGX_HAVE_WRITE_ZEROCOPY) | |
968 if (b->zerocopy_busy) { | |
969 break; | |
970 } | |
971 #endif | |
972 | |
973 if (b->shadow) { | |
974 b->shadow->pos = b->shadow->last; | |
975 } | |
976 | |
977 ctx->busy = cl->next; | |
645 | 978 |
979 if (ngx_buf_in_memory(b) || b->in_file) { | |
980 /* add data bufs only to the free buf chain */ | |
981 | |
982 cl->next = ctx->free; | |
983 ctx->free = cl; | |
984 } | |
499 | 985 } |
986 | |
829
362d156f0278
high level HTTP buffered flags should be on per-subrequest basis,
Igor Sysoev <igor@sysoev.ru>
parents:
787
diff
changeset
|
987 if (ctx->in || ctx->buf) { |
362d156f0278
high level HTTP buffered flags should be on per-subrequest basis,
Igor Sysoev <igor@sysoev.ru>
parents:
787
diff
changeset
|
988 r->buffered |= NGX_HTTP_SSI_BUFFERED; |
362d156f0278
high level HTTP buffered flags should be on per-subrequest basis,
Igor Sysoev <igor@sysoev.ru>
parents:
787
diff
changeset
|
989 |
362d156f0278
high level HTTP buffered flags should be on per-subrequest basis,
Igor Sysoev <igor@sysoev.ru>
parents:
787
diff
changeset
|
990 } else { |
362d156f0278
high level HTTP buffered flags should be on per-subrequest basis,
Igor Sysoev <igor@sysoev.ru>
parents:
787
diff
changeset
|
991 r->buffered &= ~NGX_HTTP_SSI_BUFFERED; |
362d156f0278
high level HTTP buffered flags should be on per-subrequest basis,
Igor Sysoev <igor@sysoev.ru>
parents:
787
diff
changeset
|
992 } |
362d156f0278
high level HTTP buffered flags should be on per-subrequest basis,
Igor Sysoev <igor@sysoev.ru>
parents:
787
diff
changeset
|
993 |
497 | 994 return rc; |
129
7a886b9a67dc
nginx-0.0.1-2003-08-10-20:14:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
995 } |
7a886b9a67dc
nginx-0.0.1-2003-08-10-20:14:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
996 |
127
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
997 |
489 | 998 static ngx_int_t |
999 ngx_http_ssi_parse(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx) | |
127
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1000 { |
609 | 1001 u_char *p, *value, *last, *copy_end, ch; |
497 | 1002 size_t looked; |
241
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
1003 ngx_http_ssi_state_e state; |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1004 |
497 | 1005 state = ctx->state; |
1006 looked = ctx->looked; | |
1007 last = ctx->buf->last; | |
1008 copy_end = ctx->copy_end; | |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1009 |
497 | 1010 for (p = ctx->pos; p < last; p++) { |
489 | 1011 |
1012 ch = *p; | |
1013 | |
1014 if (state == ssi_start_state) { | |
1015 | |
1016 /* the tight loop */ | |
1017 | |
499 | 1018 for ( ;; ) { |
1019 if (ch == '<') { | |
1020 copy_end = p; | |
1021 looked = 1; | |
1022 state = ssi_tag_state; | |
1023 | |
1024 goto tag_started; | |
489 | 1025 } |
1026 | |
499 | 1027 if (++p == last) { |
1028 break; | |
1029 } | |
497 | 1030 |
499 | 1031 ch = *p; |
489 | 1032 } |
1033 | |
1260
c3541b8973de
if "<!--" was on edge of buf, then ssi_sharp_state was saved in ctx->saved
Igor Sysoev <igor@sysoev.ru>
parents:
1190
diff
changeset
|
1034 ctx->state = state; |
497 | 1035 ctx->pos = p; |
1036 ctx->looked = looked; | |
1037 ctx->copy_end = p; | |
489 | 1038 |
497 | 1039 if (ctx->copy_start == NULL) { |
1040 ctx->copy_start = ctx->buf->pos; | |
489 | 1041 } |
497 | 1042 |
1043 return NGX_AGAIN; | |
1044 | |
499 | 1045 tag_started: |
1046 | |
497 | 1047 continue; |
489 | 1048 } |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1049 |
125
885ffb8cc32a
nginx-0.0.1-2003-08-06-09:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
16
diff
changeset
|
1050 switch (state) { |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1051 |
125
885ffb8cc32a
nginx-0.0.1-2003-08-06-09:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
16
diff
changeset
|
1052 case ssi_start_state: |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1053 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1054 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1055 case ssi_tag_state: |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1056 switch (ch) { |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1057 case '!': |
497 | 1058 looked = 2; |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1059 state = ssi_comment0_state; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1060 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1061 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1062 case '<': |
497 | 1063 copy_end = p; |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1064 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1065 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1066 default: |
497 | 1067 copy_end = p; |
1068 looked = 0; | |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1069 state = ssi_start_state; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1070 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1071 } |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1072 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1073 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1074 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1075 case ssi_comment0_state: |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1076 switch (ch) { |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1077 case '-': |
497 | 1078 looked = 3; |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1079 state = ssi_comment1_state; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1080 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1081 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1082 case '<': |
497 | 1083 copy_end = p; |
1084 looked = 1; | |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1085 state = ssi_tag_state; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1086 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1087 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1088 default: |
497 | 1089 copy_end = p; |
1090 looked = 0; | |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1091 state = ssi_start_state; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1092 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1093 } |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1094 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1095 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1096 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1097 case ssi_comment1_state: |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1098 switch (ch) { |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1099 case '-': |
497 | 1100 looked = 4; |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1101 state = ssi_sharp_state; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1102 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1103 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1104 case '<': |
497 | 1105 copy_end = p; |
1106 looked = 1; | |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1107 state = ssi_tag_state; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1108 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1109 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1110 default: |
497 | 1111 copy_end = p; |
1112 looked = 0; | |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1113 state = ssi_start_state; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1114 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1115 } |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1116 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1117 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1118 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1119 case ssi_sharp_state: |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1120 switch (ch) { |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1121 case '#': |
659 | 1122 if (p - ctx->pos < 4) { |
1123 ctx->saved = 0; | |
1124 } | |
497 | 1125 looked = 0; |
1126 state = ssi_precommand_state; | |
489 | 1127 break; |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1128 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1129 case '<': |
497 | 1130 copy_end = p; |
1131 looked = 1; | |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1132 state = ssi_tag_state; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1133 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1134 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1135 default: |
497 | 1136 copy_end = p; |
1137 looked = 0; | |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1138 state = ssi_start_state; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1139 break; |
14
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1140 } |
16
6ce4755737b4
nginx-0.0.1-2002-09-26-20:50:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
15
diff
changeset
|
1141 |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1142 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1143 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1144 case ssi_precommand_state: |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1145 switch (ch) { |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1146 case ' ': |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1147 case CR: |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1148 case LF: |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1149 case '\t': |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1150 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1151 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1152 default: |
489 | 1153 ctx->command.len = 1; |
497 | 1154 ctx->command.data = ngx_palloc(r->pool, |
609 | 1155 NGX_HTTP_SSI_COMMAND_LEN); |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
1156 if (ctx->command.data == NULL) { |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
1157 return NGX_ERROR; |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
1158 } |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
1159 |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1160 ctx->command.data[0] = ch; |
609 | 1161 |
597 | 1162 ctx->key = 0; |
1163 ctx->key = ngx_hash(ctx->key, ch); | |
1164 | |
497 | 1165 ctx->params.nelts = 0; |
629 | 1166 |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1167 state = ssi_command_state; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1168 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1169 } |
16
6ce4755737b4
nginx-0.0.1-2002-09-26-20:50:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
15
diff
changeset
|
1170 |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1171 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1172 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1173 case ssi_command_state: |
127
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1174 switch (ch) { |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1175 case ' ': |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1176 case CR: |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1177 case LF: |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1178 case '\t': |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1179 state = ssi_preparam_state; |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1180 break; |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1181 |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1182 case '-': |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1183 state = ssi_comment_end0_state; |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1184 break; |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1185 |
127
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1186 default: |
497 | 1187 if (ctx->command.len == NGX_HTTP_SSI_COMMAND_LEN) { |
1188 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
609 | 1189 "the \"%V%c...\" SSI command is too long", |
1190 &ctx->command, ch); | |
497 | 1191 |
1192 state = ssi_error_state; | |
1193 break; | |
127
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1194 } |
609 | 1195 |
1196 ctx->command.data[ctx->command.len++] = ch; | |
1197 ctx->key = ngx_hash(ctx->key, ch); | |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1198 } |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1199 |
14
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1200 break; |
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1201 |
127
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1202 case ssi_preparam_state: |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1203 switch (ch) { |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1204 case ' ': |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1205 case CR: |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1206 case LF: |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1207 case '\t': |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1208 break; |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1209 |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1210 case '-': |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1211 state = ssi_comment_end0_state; |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1212 break; |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1213 |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1214 default: |
499 | 1215 ctx->param = ngx_array_push(&ctx->params); |
1216 if (ctx->param == NULL) { | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
1217 return NGX_ERROR; |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
1218 } |
127
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1219 |
489 | 1220 ctx->param->key.len = 1; |
497 | 1221 ctx->param->key.data = ngx_palloc(r->pool, |
609 | 1222 NGX_HTTP_SSI_PARAM_LEN); |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
1223 if (ctx->param->key.data == NULL) { |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
1224 return NGX_ERROR; |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
1225 } |
497 | 1226 |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1227 ctx->param->key.data[0] = ch; |
127
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1228 |
489 | 1229 ctx->param->value.len = 0; |
609 | 1230 |
1231 if (ctx->value_buf == NULL) { | |
1232 ctx->param->value.data = ngx_palloc(r->pool, | |
1233 ctx->value_len); | |
1234 if (ctx->param->value.data == NULL) { | |
1235 return NGX_ERROR; | |
1236 } | |
1237 | |
1238 } else { | |
1239 ctx->param->value.data = ctx->value_buf; | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
1240 } |
127
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1241 |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1242 state = ssi_param_state; |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1243 break; |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1244 } |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1245 |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1246 break; |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1247 |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1248 case ssi_param_state: |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1249 switch (ch) { |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1250 case ' ': |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1251 case CR: |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1252 case LF: |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1253 case '\t': |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1254 state = ssi_preequal_state; |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1255 break; |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1256 |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1257 case '=': |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1258 state = ssi_prevalue_state; |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1259 break; |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1260 |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1261 case '-': |
497 | 1262 state = ssi_error_end0_state; |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1263 |
497 | 1264 ctx->param->key.data[ctx->param->key.len++] = ch; |
1265 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1266 "invalid \"%V\" parameter in \"%V\" SSI command", | |
1267 &ctx->param->key, &ctx->command); | |
1268 break; | |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1269 |
127
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1270 default: |
497 | 1271 if (ctx->param->key.len == NGX_HTTP_SSI_PARAM_LEN) { |
1272 state = ssi_error_state; | |
1273 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
609 | 1274 "too long \"%V%c...\" parameter in " |
497 | 1275 "\"%V\" SSI command", |
609 | 1276 &ctx->param->key, ch, &ctx->command); |
497 | 1277 break; |
127
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1278 } |
609 | 1279 |
1280 ctx->param->key.data[ctx->param->key.len++] = ch; | |
127
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1281 } |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1282 |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1283 break; |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1284 |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1285 case ssi_preequal_state: |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1286 switch (ch) { |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1287 case ' ': |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1288 case CR: |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1289 case LF: |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1290 case '\t': |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1291 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1292 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1293 case '=': |
127
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1294 state = ssi_prevalue_state; |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1295 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1296 |
497 | 1297 default: |
1298 if (ch == '-') { | |
1299 state = ssi_error_end0_state; | |
1300 } else { | |
1301 state = ssi_error_state; | |
1302 } | |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1303 |
497 | 1304 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
1305 "unexpected \"%c\" symbol after \"%V\" " | |
1306 "parameter in \"%V\" SSI command", | |
1307 ch, &ctx->param->key, &ctx->command); | |
1308 break; | |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1309 } |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1310 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1311 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1312 |
127
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1313 case ssi_prevalue_state: |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1314 switch (ch) { |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1315 case ' ': |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1316 case CR: |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1317 case LF: |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1318 case '\t': |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1319 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1320 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1321 case '"': |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1322 state = ssi_double_quoted_value_state; |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1323 break; |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1324 |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1325 case '\'': |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1326 state = ssi_quoted_value_state; |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1327 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1328 |
497 | 1329 default: |
1330 if (ch == '-') { | |
1331 state = ssi_error_end0_state; | |
1332 } else { | |
1333 state = ssi_error_state; | |
1334 } | |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1335 |
497 | 1336 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
1337 "unexpected \"%c\" symbol before value of " | |
1338 "\"%V\" parameter in \"%V\" SSI command", | |
1339 ch, &ctx->param->key, &ctx->command); | |
1340 break; | |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1341 } |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1342 |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1343 break; |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1344 |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1345 case ssi_double_quoted_value_state: |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1346 switch (ch) { |
559 | 1347 case '"': |
1348 state = ssi_postparam_state; | |
1349 break; | |
1350 | |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1351 case '\\': |
497 | 1352 ctx->saved_state = ssi_double_quoted_value_state; |
1353 state = ssi_quoted_symbol_state; | |
559 | 1354 |
1355 /* fall through */ | |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1356 |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1357 default: |
497 | 1358 if (ctx->param->value.len == ctx->value_len) { |
1359 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
609 | 1360 "too long \"%V%c...\" value of \"%V\" " |
1361 "parameter in \"%V\" SSI command", | |
1362 &ctx->param->value, ch, &ctx->param->key, | |
497 | 1363 &ctx->command); |
1364 state = ssi_error_state; | |
1365 break; | |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1366 } |
609 | 1367 |
1368 ctx->param->value.data[ctx->param->value.len++] = ch; | |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1369 } |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1370 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1371 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1372 |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1373 case ssi_quoted_value_state: |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1374 switch (ch) { |
559 | 1375 case '\'': |
1376 state = ssi_postparam_state; | |
1377 break; | |
1378 | |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1379 case '\\': |
497 | 1380 ctx->saved_state = ssi_quoted_value_state; |
1381 state = ssi_quoted_symbol_state; | |
559 | 1382 |
1383 /* fall through */ | |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1384 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1385 default: |
497 | 1386 if (ctx->param->value.len == ctx->value_len) { |
1387 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
609 | 1388 "too long \"%V%c...\" value of \"%V\" " |
1389 "parameter in \"%V\" SSI command", | |
1390 &ctx->param->value, ch, &ctx->param->key, | |
497 | 1391 &ctx->command); |
1392 state = ssi_error_state; | |
1393 break; | |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1394 } |
609 | 1395 |
1396 ctx->param->value.data[ctx->param->value.len++] = ch; | |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1397 } |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1398 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1399 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1400 |
497 | 1401 case ssi_quoted_symbol_state: |
559 | 1402 state = ctx->saved_state; |
1403 | |
497 | 1404 ctx->param->value.data[ctx->param->value.len++] = ch; |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1405 |
497 | 1406 break; |
1407 | |
1408 case ssi_postparam_state: | |
609 | 1409 |
651 | 1410 if (ctx->param->value.len + 1 < ctx->value_len / 2) { |
1411 value = ngx_palloc(r->pool, ctx->param->value.len + 1); | |
609 | 1412 if (value == NULL) { |
1413 return NGX_ERROR; | |
1414 } | |
1415 | |
1416 ngx_memcpy(value, ctx->param->value.data, | |
1417 ctx->param->value.len); | |
1418 | |
1419 ctx->value_buf = ctx->param->value.data; | |
1420 ctx->param->value.data = value; | |
1421 | |
1422 } else { | |
1423 ctx->value_buf = NULL; | |
1424 } | |
1425 | |
497 | 1426 switch (ch) { |
1427 case ' ': | |
1428 case CR: | |
1429 case LF: | |
1430 case '\t': | |
1431 state = ssi_preparam_state; | |
1432 break; | |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1433 |
497 | 1434 case '-': |
1435 state = ssi_comment_end0_state; | |
1436 break; | |
1437 | |
1438 default: | |
1439 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1440 "unexpected \"%c\" symbol after \"%V\" value " | |
1441 "of \"%V\" parameter in \"%V\" SSI command", | |
1442 ch, &ctx->param->value, &ctx->param->key, | |
1443 &ctx->command); | |
1444 state = ssi_error_state; | |
1445 break; | |
1446 } | |
1447 | |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1448 break; |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1449 |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1450 case ssi_comment_end0_state: |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1451 switch (ch) { |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1452 case '-': |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1453 state = ssi_comment_end1_state; |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1454 break; |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1455 |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1456 default: |
497 | 1457 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
1458 "unexpected \"%c\" symbol in \"%V\" SSI command", | |
1459 ch, &ctx->command); | |
1460 state = ssi_error_state; | |
1461 break; | |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1462 } |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1463 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1464 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1465 |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1466 case ssi_comment_end1_state: |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1467 switch (ch) { |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1468 case '>': |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1469 ctx->state = ssi_start_state; |
497 | 1470 ctx->pos = p + 1; |
1471 ctx->looked = looked; | |
1472 ctx->copy_end = copy_end; | |
1473 | |
1474 if (ctx->copy_start == NULL && copy_end) { | |
1475 ctx->copy_start = ctx->buf->pos; | |
1476 } | |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1477 |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1478 return NGX_OK; |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1479 |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1480 default: |
497 | 1481 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
1482 "unexpected \"%c\" symbol in \"%V\" SSI command", | |
1483 ch, &ctx->command); | |
1484 state = ssi_error_state; | |
1485 break; | |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1486 } |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1487 |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1488 break; |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1489 |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1490 case ssi_error_state: |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1491 switch (ch) { |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1492 case '-': |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1493 state = ssi_error_end0_state; |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1494 break; |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1495 |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1496 default: |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1497 break; |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1498 } |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1499 |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1500 break; |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1501 |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1502 case ssi_error_end0_state: |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1503 switch (ch) { |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1504 case '-': |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1505 state = ssi_error_end1_state; |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1506 break; |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1507 |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1508 default: |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1509 state = ssi_error_state; |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1510 break; |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1511 } |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1512 |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1513 break; |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1514 |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1515 case ssi_error_end1_state: |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1516 switch (ch) { |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1517 case '>': |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1518 ctx->state = ssi_start_state; |
497 | 1519 ctx->pos = p + 1; |
1520 ctx->looked = looked; | |
1521 ctx->copy_end = copy_end; | |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1522 |
497 | 1523 if (ctx->copy_start == NULL && copy_end) { |
1524 ctx->copy_start = ctx->buf->pos; | |
1525 } | |
1526 | |
1527 return NGX_HTTP_SSI_ERROR; | |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1528 |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1529 default: |
241
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
1530 state = ssi_error_state; |
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
1531 break; |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1532 } |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1533 |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1534 break; |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1535 } |
16
6ce4755737b4
nginx-0.0.1-2002-09-26-20:50:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
15
diff
changeset
|
1536 } |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1537 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1538 ctx->state = state; |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1539 ctx->pos = p; |
497 | 1540 ctx->looked = looked; |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1541 |
497 | 1542 ctx->copy_end = (state == ssi_start_state) ? p : copy_end; |
1543 | |
1544 if (ctx->copy_start == NULL && ctx->copy_end) { | |
1545 ctx->copy_start = ctx->buf->pos; | |
1546 } | |
1547 | |
1548 return NGX_AGAIN; | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
1549 } |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
1550 |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
1551 |
553 | 1552 static ngx_str_t * |
611 | 1553 ngx_http_ssi_get_variable(ngx_http_request_t *r, ngx_str_t *name, |
1554 ngx_uint_t key) | |
553 | 1555 { |
1556 ngx_uint_t i; | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1557 ngx_list_part_t *part; |
553 | 1558 ngx_http_ssi_var_t *var; |
1559 ngx_http_ssi_ctx_t *ctx; | |
1560 | |
1561 ctx = ngx_http_get_module_ctx(r->main, ngx_http_ssi_filter_module); | |
1562 | |
667 | 1563 if (ctx->variables == NULL) { |
1564 return NULL; | |
1565 } | |
1566 | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1567 part = &ctx->variables->part; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1568 var = part->elts; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1569 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1570 for (i = 0; /* void */ ; i++) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1571 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1572 if (i >= part->nelts) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1573 if (part->next == NULL) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1574 break; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1575 } |
787
b310630d129e
style fix: remove trailing spaces
Igor Sysoev <igor@sysoev.ru>
parents:
784
diff
changeset
|
1576 |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1577 part = part->next; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1578 var = part->elts; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1579 i = 0; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1580 } |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1581 |
553 | 1582 if (name->len != var[i].name.len) { |
1583 continue; | |
1584 } | |
1585 | |
611 | 1586 if (key != var[i].key) { |
1587 continue; | |
1588 } | |
1589 | |
1590 if (ngx_strncmp(name->data, var[i].name.data, name->len) == 0) { | |
553 | 1591 return &var[i].value; |
1592 } | |
1593 } | |
1594 | |
1595 return NULL; | |
1596 } | |
1597 | |
1598 | |
1599 static ngx_int_t | |
1600 ngx_http_ssi_evaluate_string(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, | |
1601 ngx_str_t *text, ngx_uint_t flags) | |
1602 { | |
573 | 1603 u_char ch, *p, **value, *data, *part_data; |
1604 size_t *size, len, prefix, part_len; | |
1605 ngx_str_t var, *val; | |
611 | 1606 ngx_int_t key; |
651 | 1607 ngx_uint_t i, j, n, bracket, quoted; |
553 | 1608 ngx_array_t lengths, values; |
1609 ngx_http_variable_value_t *vv; | |
1610 | |
1611 n = ngx_http_script_variables_count(text); | |
1612 | |
1613 if (n == 0) { | |
1614 | |
657 | 1615 data = text->data; |
1616 p = data; | |
1617 | |
1618 if ((flags & NGX_HTTP_SSI_ADD_PREFIX) && text->data[0] != '/') { | |
1619 | |
553 | 1620 for (prefix = r->uri.len; prefix; prefix--) { |
1621 if (r->uri.data[prefix - 1] == '/') { | |
1622 break; | |
1623 } | |
1624 } | |
1625 | |
1626 if (prefix) { | |
1627 len = prefix + text->len; | |
1628 | |
1629 data = ngx_palloc(r->pool, len); | |
1630 if (data == NULL) { | |
1631 return NGX_ERROR; | |
1632 } | |
1633 | |
573 | 1634 p = ngx_copy(data, r->uri.data, prefix); |
553 | 1635 } |
1636 } | |
1637 | |
657 | 1638 quoted = 0; |
1639 | |
1640 for (i = 0 ; i < text->len; i++) { | |
1641 ch = text->data[i]; | |
1642 | |
1643 if (!quoted) { | |
1644 | |
1645 if (ch == '\\') { | |
1646 quoted = 1; | |
1647 continue; | |
1648 } | |
1649 | |
1650 } else { | |
1651 quoted = 0; | |
1652 | |
1653 if (ch != '\\' && ch != '\'' && ch != '"' && ch != '$') { | |
1654 *p++ = '\\'; | |
1655 } | |
1656 } | |
1657 | |
1658 *p++ = ch; | |
1659 } | |
1660 | |
1661 text->len = p - data; | |
1662 text->data = data; | |
1663 | |
553 | 1664 return NGX_OK; |
1665 } | |
1666 | |
1667 if (ngx_array_init(&lengths, r->pool, 8, sizeof(size_t *)) != NGX_OK) { | |
1668 return NGX_ERROR; | |
1669 } | |
1670 | |
1671 if (ngx_array_init(&values, r->pool, 8, sizeof(u_char *)) != NGX_OK) { | |
1672 return NGX_ERROR; | |
1673 } | |
1674 | |
1675 len = 0; | |
1676 i = 0; | |
1677 | |
1678 while (i < text->len) { | |
1679 | |
1680 if (text->data[i] == '$') { | |
1681 | |
1682 var.len = 0; | |
1683 | |
1684 if (++i == text->len) { | |
1685 goto invalid_variable; | |
1686 } | |
1687 | |
1688 if (text->data[i] == '{') { | |
1689 bracket = 1; | |
1690 | |
1691 if (++i == text->len) { | |
1692 goto invalid_variable; | |
1693 } | |
1694 | |
1695 var.data = &text->data[i]; | |
1696 | |
1697 } else { | |
1698 bracket = 0; | |
1699 var.data = &text->data[i]; | |
1700 } | |
1701 | |
1702 for ( /* void */ ; i < text->len; i++, var.len++) { | |
1703 ch = text->data[i]; | |
1704 | |
1705 if (ch == '}' && bracket) { | |
1706 i++; | |
1707 bracket = 0; | |
1708 break; | |
1709 } | |
1710 | |
1711 if ((ch >= 'A' && ch <= 'Z') | |
1712 || (ch >= 'a' && ch <= 'z') | |
1713 || (ch >= '0' && ch <= '9') | |
1714 || ch == '_') | |
1715 { | |
1716 continue; | |
1717 } | |
1718 | |
1719 break; | |
1720 } | |
1721 | |
1722 if (bracket) { | |
1723 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1724 "the closing bracket in \"%V\" " | |
1725 "variable is missing", &var); | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1726 return NGX_HTTP_SSI_ERROR; |
553 | 1727 } |
1728 | |
577 | 1729 if (var.len == 0) { |
553 | 1730 goto invalid_variable; |
1731 } | |
1732 | |
611 | 1733 key = 0; |
1734 | |
553 | 1735 for (j = 0; j < var.len; j++) { |
1736 var.data[j] = ngx_tolower(var.data[j]); | |
611 | 1737 key = ngx_hash(key, var.data[j]); |
553 | 1738 } |
1739 | |
611 | 1740 val = ngx_http_ssi_get_variable(r, &var, key); |
553 | 1741 |
1742 if (val == NULL) { | |
635 | 1743 vv = ngx_http_get_variable(r, &var, key, |
1744 flags & NGX_HTTP_SSI_EXPR_TEST); | |
553 | 1745 if (vv == NULL) { |
1746 return NGX_ERROR; | |
1747 } | |
1748 | |
573 | 1749 if (vv->not_found) { |
553 | 1750 continue; |
1751 } | |
1752 | |
573 | 1753 part_data = vv->data; |
1754 part_len = vv->len; | |
553 | 1755 |
1756 } else { | |
573 | 1757 part_data = val->data; |
1758 part_len = val->len; | |
553 | 1759 } |
1760 | |
1761 } else { | |
573 | 1762 part_data = &text->data[i]; |
651 | 1763 quoted = 0; |
573 | 1764 |
1765 for (p = part_data; i < text->len; i++) { | |
559 | 1766 ch = text->data[i]; |
1767 | |
651 | 1768 if (!quoted) { |
1769 | |
1770 if (ch == '\\') { | |
1771 quoted = 1; | |
1772 continue; | |
1773 } | |
1774 | |
1775 if (ch == '$') { | |
559 | 1776 break; |
1777 } | |
1778 | |
651 | 1779 } else { |
1780 quoted = 0; | |
1781 | |
1782 if (ch != '\\' && ch != '\'' && ch != '"' && ch != '$') { | |
1783 *p++ = '\\'; | |
1784 } | |
559 | 1785 } |
1786 | |
1787 *p++ = ch; | |
553 | 1788 } |
559 | 1789 |
573 | 1790 part_len = p - part_data; |
553 | 1791 } |
1792 | |
573 | 1793 len += part_len; |
553 | 1794 |
1795 size = ngx_array_push(&lengths); | |
1796 if (size == NULL) { | |
1797 return NGX_ERROR; | |
1798 } | |
1799 | |
573 | 1800 *size = part_len; |
553 | 1801 |
1802 value = ngx_array_push(&values); | |
1803 if (value == NULL) { | |
1804 return NGX_ERROR; | |
1805 } | |
1806 | |
573 | 1807 *value = part_data; |
553 | 1808 } |
1809 | |
1810 prefix = 0; | |
1811 | |
1812 size = lengths.elts; | |
1813 value = values.elts; | |
1814 | |
1815 if (flags & NGX_HTTP_SSI_ADD_PREFIX) { | |
1816 for (i = 0; i < values.nelts; i++) { | |
1817 if (size[i] != 0) { | |
1818 if (*value[i] != '/') { | |
1819 for (prefix = r->uri.len; prefix; prefix--) { | |
1820 if (r->uri.data[prefix - 1] == '/') { | |
1821 len += prefix; | |
1822 break; | |
1823 } | |
1824 } | |
1825 } | |
1826 | |
1827 break; | |
1828 } | |
1829 } | |
1830 } | |
1831 | |
629 | 1832 p = ngx_palloc(r->pool, len + ((flags & NGX_HTTP_SSI_ADD_ZERO) ? 1 : 0)); |
553 | 1833 if (p == NULL) { |
1834 return NGX_ERROR; | |
1835 } | |
1836 | |
1837 text->len = len; | |
1838 text->data = p; | |
1839 | |
573 | 1840 p = ngx_copy(p, r->uri.data, prefix); |
553 | 1841 |
1842 for (i = 0; i < values.nelts; i++) { | |
573 | 1843 p = ngx_copy(p, value[i], size[i]); |
553 | 1844 } |
1845 | |
1846 return NGX_OK; | |
1847 | |
1848 invalid_variable: | |
1849 | |
1850 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1851 "invalid variable name in \"%V\"", text); | |
1852 | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1853 return NGX_HTTP_SSI_ERROR; |
553 | 1854 } |
1855 | |
1856 | |
1857 static ngx_int_t | |
1858 ngx_http_ssi_include(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, | |
1859 ngx_str_t **params) | |
1860 { | |
1593 | 1861 u_char *dst, *src; |
1862 size_t len; | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1863 ngx_int_t rc, key; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1864 ngx_str_t *uri, *file, *wait, *set, *stub, args; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1865 ngx_buf_t *b; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1866 ngx_uint_t flags, i; |
784
5a164305b960
fix building by Debian gcc-4.1.2 amd64
Igor Sysoev <igor@sysoev.ru>
parents:
777
diff
changeset
|
1867 ngx_chain_t *cl, *tl, **ll, *out; |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1868 ngx_http_request_t *sr; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1869 ngx_http_ssi_var_t *var; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1870 ngx_http_ssi_ctx_t *mctx; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1871 ngx_http_ssi_block_t *bl; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1872 ngx_http_post_subrequest_t *psr; |
553 | 1873 |
1874 uri = params[NGX_HTTP_SSI_INCLUDE_VIRTUAL]; | |
1875 file = params[NGX_HTTP_SSI_INCLUDE_FILE]; | |
645 | 1876 wait = params[NGX_HTTP_SSI_INCLUDE_WAIT]; |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1877 set = params[NGX_HTTP_SSI_INCLUDE_SET]; |
667 | 1878 stub = params[NGX_HTTP_SSI_INCLUDE_STUB]; |
553 | 1879 |
1880 if (uri && file) { | |
1881 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1882 "inlcusion may be either virtual=\"%V\" or file=\"%V\"", | |
1883 uri, file); | |
1884 return NGX_HTTP_SSI_ERROR; | |
1885 } | |
1886 | |
1887 if (uri == NULL && file == NULL) { | |
1888 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1889 "no parameter in \"include\" SSI command"); | |
1890 return NGX_HTTP_SSI_ERROR; | |
1891 } | |
1892 | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1893 if (set && stub) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1894 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1895 "\"set\" and \"stub\" may not be used together " |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1896 "in \"include\" SSI command"); |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1897 return NGX_HTTP_SSI_ERROR; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1898 } |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1899 |
645 | 1900 if (wait) { |
1901 if (uri == NULL) { | |
1902 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
667 | 1903 "\"wait\" may not be used with file=\"%V\"", file); |
645 | 1904 return NGX_HTTP_SSI_ERROR; |
1905 } | |
1906 | |
1107
db7c468c447d
ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents:
1025
diff
changeset
|
1907 if (wait->len == 2 |
db7c468c447d
ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents:
1025
diff
changeset
|
1908 && ngx_strncasecmp(wait->data, (u_char *) "no", 2) == 0) |
db7c468c447d
ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents:
1025
diff
changeset
|
1909 { |
645 | 1910 wait = NULL; |
1911 | |
1107
db7c468c447d
ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents:
1025
diff
changeset
|
1912 } else if (wait->len != 3 |
db7c468c447d
ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents:
1025
diff
changeset
|
1913 || ngx_strncasecmp(wait->data, (u_char *) "yes", 3) != 0) |
645 | 1914 { |
1915 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1916 "invalid value \"%V\" in the \"wait\" parameter", | |
667 | 1917 wait); |
645 | 1918 return NGX_HTTP_SSI_ERROR; |
1919 } | |
1920 } | |
1921 | |
553 | 1922 if (uri == NULL) { |
1923 uri = file; | |
1924 } | |
1925 | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1926 rc = ngx_http_ssi_evaluate_string(r, ctx, uri, NGX_HTTP_SSI_ADD_PREFIX); |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1927 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1928 if (rc != NGX_OK) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1929 return rc; |
553 | 1930 } |
1931 | |
1593 | 1932 dst = uri->data; |
1933 src = uri->data; | |
1934 | |
1935 ngx_unescape_uri(&dst, &src, uri->len, NGX_UNESCAPE_URI); | |
1936 | |
1937 len = (uri->data + uri->len) - src; | |
1938 if (len) { | |
1939 dst = ngx_copy(dst, src, len); | |
1940 } | |
1941 | |
1942 uri->len = dst - uri->data; | |
1943 | |
1944 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1945 "ssi include: \"%V\"", uri); | |
1946 | |
553 | 1947 args.len = 0; |
1948 args.data = NULL; | |
573 | 1949 flags = 0; |
1950 | |
1951 if (ngx_http_parse_unsafe_uri(r, uri, &args, &flags) != NGX_OK) { | |
1952 return NGX_HTTP_SSI_ERROR; | |
553 | 1953 } |
1954 | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1955 psr = NULL; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1956 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1957 mctx = ngx_http_get_module_ctx(r->main, ngx_http_ssi_filter_module); |
667 | 1958 |
1959 if (stub) { | |
1960 if (mctx->blocks) { | |
1961 bl = mctx->blocks->elts; | |
1962 for (i = 0; i < mctx->blocks->nelts; i++) { | |
1963 if (stub->len == bl[i].name.len | |
1964 && ngx_strncmp(stub->data, bl[i].name.data, stub->len) == 0) | |
1965 { | |
1966 goto found; | |
1967 } | |
1968 } | |
1969 } | |
1970 | |
1971 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1972 "\"stub\"=\"%V\" for \"include\" not found", stub); | |
1973 return NGX_HTTP_SSI_ERROR; | |
1974 | |
1975 found: | |
1976 | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1977 psr = ngx_palloc(r->pool, sizeof(ngx_http_post_subrequest_t)); |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1978 if (psr == NULL) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1979 return NGX_ERROR; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1980 } |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1981 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1982 psr->handler = ngx_http_ssi_stub_output; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1983 |
667 | 1984 if (bl[i].count++) { |
1985 | |
784
5a164305b960
fix building by Debian gcc-4.1.2 amd64
Igor Sysoev <igor@sysoev.ru>
parents:
777
diff
changeset
|
1986 ll = &out; |
667 | 1987 |
1988 for (tl = bl[i].bufs; tl; tl = tl->next) { | |
1989 | |
1990 if (ctx->free) { | |
1991 cl = ctx->free; | |
1992 ctx->free = ctx->free->next; | |
1993 b = cl->buf; | |
1994 | |
1995 } else { | |
1996 b = ngx_alloc_buf(r->pool); | |
1997 if (b == NULL) { | |
1998 return NGX_ERROR; | |
1999 } | |
2000 | |
2001 cl = ngx_alloc_chain_link(r->pool); | |
2002 if (cl == NULL) { | |
2003 return NGX_ERROR; | |
2004 } | |
2005 | |
2006 cl->buf = b; | |
2007 } | |
2008 | |
2009 ngx_memcpy(b, tl->buf, sizeof(ngx_buf_t)); | |
2010 | |
2011 b->pos = b->start; | |
2012 | |
2013 *ll = cl; | |
2014 cl->next = NULL; | |
2015 ll = &cl->next; | |
2016 } | |
2017 | |
784
5a164305b960
fix building by Debian gcc-4.1.2 amd64
Igor Sysoev <igor@sysoev.ru>
parents:
777
diff
changeset
|
2018 psr->data = out; |
5a164305b960
fix building by Debian gcc-4.1.2 amd64
Igor Sysoev <igor@sysoev.ru>
parents:
777
diff
changeset
|
2019 |
667 | 2020 } else { |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2021 psr->data = bl[i].bufs; |
667 | 2022 } |
2023 } | |
2024 | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2025 if (set) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2026 key = 0; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2027 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2028 for (i = 0; i < set->len; i++) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2029 set->data[i] = ngx_tolower(set->data[i]); |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2030 key = ngx_hash(key, set->data[i]); |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2031 } |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2032 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2033 psr = ngx_palloc(r->pool, sizeof(ngx_http_post_subrequest_t)); |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2034 if (psr == NULL) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2035 return NGX_ERROR; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2036 } |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2037 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2038 psr->handler = ngx_http_ssi_set_variable; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2039 psr->data = ngx_http_ssi_get_variable(r, set, key); |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2040 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2041 if (psr->data == NULL) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2042 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2043 if (mctx->variables == NULL) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2044 mctx->variables = ngx_list_create(r->pool, 4, |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2045 sizeof(ngx_http_ssi_var_t)); |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2046 if (mctx->variables == NULL) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2047 return NGX_ERROR; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2048 } |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2049 } |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2050 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2051 var = ngx_list_push(mctx->variables); |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2052 if (var == NULL) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2053 return NGX_ERROR; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2054 } |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2055 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2056 var->name = *set; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2057 var->key = key; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2058 var->value = ngx_http_ssi_null_string; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2059 psr->data = &var->value; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2060 } |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2061 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2062 flags |= NGX_HTTP_SUBREQUEST_IN_MEMORY; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2063 } |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2064 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2065 rc = ngx_http_subrequest(r, uri, &args, &sr, psr, flags); |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2066 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2067 if (rc == NGX_DONE) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2068 return NGX_DONE; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2069 } |
645 | 2070 |
2071 if (rc == NGX_ERROR) { | |
553 | 2072 return NGX_HTTP_SSI_ERROR; |
2073 } | |
2074 | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2075 if (wait == NULL && set == NULL) { |
645 | 2076 return NGX_OK; |
2077 } | |
2078 | |
2079 if (rc == NGX_AGAIN) { | |
758
86bb73dc8d40
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
710
diff
changeset
|
2080 if (ctx->wait == NULL) { |
86bb73dc8d40
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
710
diff
changeset
|
2081 ctx->wait = sr; |
86bb73dc8d40
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
710
diff
changeset
|
2082 |
86bb73dc8d40
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
710
diff
changeset
|
2083 } else { |
86bb73dc8d40
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
710
diff
changeset
|
2084 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
86bb73dc8d40
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
710
diff
changeset
|
2085 "only one subrequest may be waited at the same time"); |
86bb73dc8d40
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
710
diff
changeset
|
2086 } |
645 | 2087 } |
2088 | |
2089 return rc; | |
553 | 2090 } |
2091 | |
2092 | |
497 | 2093 static ngx_int_t |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2094 ngx_http_ssi_stub_output(ngx_http_request_t *r, void *data, ngx_int_t rc) |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2095 { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2096 ngx_chain_t *out; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2097 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2098 if (rc == NGX_ERROR || r->connection->error || r->request_output) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2099 return rc; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2100 } |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2101 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2102 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2103 "ssi stub output: \"%V?%V\"", &r->uri, &r->args); |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2104 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2105 out = data; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2106 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2107 if (!r->header_sent) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2108 if (ngx_http_set_content_type(r) == NGX_ERROR) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2109 return NGX_ERROR; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2110 } |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2111 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2112 if (ngx_http_send_header(r) == NGX_ERROR) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2113 return NGX_ERROR; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2114 } |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2115 } |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2116 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2117 return ngx_http_output_filter(r, out); |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2118 } |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2119 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2120 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2121 static ngx_int_t |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2122 ngx_http_ssi_set_variable(ngx_http_request_t *r, void *data, ngx_int_t rc) |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2123 { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2124 ngx_str_t *value = data; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2125 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2126 if (r->upstream) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2127 value->len = r->upstream->buffer.last - r->upstream->buffer.pos; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2128 value->data = r->upstream->buffer.pos; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2129 } |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2130 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2131 return rc; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2132 } |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2133 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2134 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2135 static ngx_int_t |
497 | 2136 ngx_http_ssi_echo(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, |
2137 ngx_str_t **params) | |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
2138 { |
1545 | 2139 u_char *p; |
2140 uintptr_t len; | |
611 | 2141 ngx_int_t key; |
501 | 2142 ngx_uint_t i; |
499 | 2143 ngx_buf_t *b; |
1545 | 2144 ngx_str_t *var, *value, *enc, text; |
499 | 2145 ngx_chain_t *cl; |
501 | 2146 ngx_http_variable_value_t *vv; |
497 | 2147 |
2148 var = params[NGX_HTTP_SSI_ECHO_VAR]; | |
2149 | |
643 | 2150 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
2151 "ssi echo \"%V\"", var); | |
2152 | |
611 | 2153 key = 0; |
2154 | |
2155 for (i = 0; i < var->len; i++) { | |
2156 var->data[i] = ngx_tolower(var->data[i]); | |
2157 key = ngx_hash(key, var->data[i]); | |
2158 } | |
2159 | |
2160 value = ngx_http_ssi_get_variable(r, var, key); | |
553 | 2161 |
2162 if (value == NULL) { | |
635 | 2163 vv = ngx_http_get_variable(r, var, key, 1); |
553 | 2164 |
2165 if (vv == NULL) { | |
2166 return NGX_HTTP_SSI_ERROR; | |
2167 } | |
2168 | |
573 | 2169 if (!vv->not_found) { |
2170 text.data = vv->data; | |
2171 text.len = vv->len; | |
2172 value = &text; | |
553 | 2173 } |
501 | 2174 } |
497 | 2175 |
553 | 2176 if (value == NULL) { |
499 | 2177 value = params[NGX_HTTP_SSI_ECHO_DEFAULT]; |
2178 | |
2179 if (value == NULL) { | |
2180 value = &ngx_http_ssi_none; | |
2181 | |
2182 } else if (value->len == 0) { | |
2183 return NGX_OK; | |
2184 } | |
2185 | |
2186 } else { | |
2187 if (value->len == 0) { | |
2188 return NGX_OK; | |
2189 } | |
2190 } | |
2191 | |
1545 | 2192 enc = params[NGX_HTTP_SSI_ECHO_ENCODING]; |
2193 | |
2194 if (enc) { | |
2195 if (enc->len == 4 && ngx_strncmp(enc->data, "none", 4) == 0) { | |
2196 | |
2197 ctx->encoding = NGX_HTTP_SSI_NO_ENCODING; | |
2198 | |
2199 } else if (enc->len == 3 && ngx_strncmp(enc->data, "url", 3) == 0) { | |
2200 | |
2201 ctx->encoding = NGX_HTTP_SSI_URL_ENCODING; | |
2202 | |
2203 } else if (enc->len == 6 && ngx_strncmp(enc->data, "entity", 6) == 0) { | |
2204 | |
2205 ctx->encoding = NGX_HTTP_SSI_ENTITY_ENCODING; | |
2206 | |
2207 } else { | |
2208 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
2209 "unknown encoding \"%V\" in the \"echo\" command", | |
2210 enc); | |
2211 } | |
2212 } | |
2213 | |
2214 switch (ctx->encoding) { | |
2215 | |
2216 case NGX_HTTP_SSI_NO_ENCODING: | |
2217 break; | |
2218 | |
2219 case NGX_HTTP_SSI_URL_ENCODING: | |
2220 len = 2 * ngx_escape_uri(NULL, value->data, value->len, | |
2221 NGX_ESCAPE_HTML); | |
2222 | |
2223 if (len) { | |
2224 p = ngx_palloc(r->pool, value->len + len); | |
2225 if (p == NULL) { | |
2226 return NGX_HTTP_SSI_ERROR; | |
2227 } | |
2228 | |
2229 (void) ngx_escape_uri(p, value->data, value->len, NGX_ESCAPE_HTML); | |
2230 | |
2231 value->len += len; | |
2232 value->data = p; | |
2233 } | |
2234 | |
2235 break; | |
2236 | |
2237 case NGX_HTTP_SSI_ENTITY_ENCODING: | |
2238 len = ngx_escape_html(NULL, value->data, value->len); | |
2239 | |
2240 if (len) { | |
2241 p = ngx_palloc(r->pool, value->len + len); | |
2242 if (p == NULL) { | |
2243 return NGX_HTTP_SSI_ERROR; | |
2244 } | |
2245 | |
2246 (void) ngx_escape_html(p, value->data, value->len); | |
2247 | |
2248 value->len += len; | |
2249 value->data = p; | |
2250 } | |
2251 | |
2252 break; | |
2253 } | |
2254 | |
499 | 2255 b = ngx_calloc_buf(r->pool); |
2256 if (b == NULL) { | |
2257 return NGX_HTTP_SSI_ERROR; | |
2258 } | |
2259 | |
2260 cl = ngx_alloc_chain_link(r->pool); | |
2261 if (cl == NULL) { | |
497 | 2262 return NGX_HTTP_SSI_ERROR; |
2263 } | |
2264 | |
2265 b->memory = 1; | |
2266 b->pos = value->data; | |
2267 b->last = value->data + value->len; | |
2268 | |
2269 cl->buf = b; | |
2270 cl->next = NULL; | |
2271 *ctx->last_out = cl; | |
2272 ctx->last_out = &cl->next; | |
2273 | |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
2274 return NGX_OK; |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
2275 } |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
2276 |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
2277 |
509 | 2278 static ngx_int_t |
2279 ngx_http_ssi_config(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, | |
2280 ngx_str_t **params) | |
2281 { | |
2282 ngx_str_t *value; | |
2283 | |
2284 value = params[NGX_HTTP_SSI_CONFIG_TIMEFMT]; | |
2285 | |
2286 if (value) { | |
589 | 2287 ctx->timefmt.len = value->len; |
2288 ctx->timefmt.data = ngx_palloc(r->pool, value->len + 1); | |
2289 if (ctx->timefmt.data == NULL) { | |
2290 return NGX_HTTP_SSI_ERROR; | |
2291 } | |
2292 | |
2293 ngx_cpystrn(ctx->timefmt.data, value->data, value->len + 1); | |
509 | 2294 } |
2295 | |
547 | 2296 value = params[NGX_HTTP_SSI_CONFIG_ERRMSG]; |
2297 | |
2298 if (value) { | |
2299 ctx->errmsg = *value; | |
2300 } | |
2301 | |
509 | 2302 return NGX_OK; |
2303 } | |
2304 | |
2305 | |
2306 static ngx_int_t | |
553 | 2307 ngx_http_ssi_set(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, |
509 | 2308 ngx_str_t **params) |
2309 { | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2310 ngx_int_t key, rc; |
611 | 2311 ngx_uint_t i; |
553 | 2312 ngx_str_t *name, *value, *vv; |
2313 ngx_http_ssi_var_t *var; | |
2314 ngx_http_ssi_ctx_t *mctx; | |
2315 | |
2316 mctx = ngx_http_get_module_ctx(r->main, ngx_http_ssi_filter_module); | |
2317 | |
667 | 2318 if (mctx->variables == NULL) { |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2319 mctx->variables = ngx_list_create(r->pool, 4, |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2320 sizeof(ngx_http_ssi_var_t)); |
667 | 2321 if (mctx->variables == NULL) { |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2322 return NGX_ERROR; |
509 | 2323 } |
2324 } | |
2325 | |
553 | 2326 name = params[NGX_HTTP_SSI_SET_VAR]; |
2327 value = params[NGX_HTTP_SSI_SET_VALUE]; | |
2328 | |
643 | 2329 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
2330 "ssi set \"%V\" \"%V\"", name, value); | |
2331 | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2332 rc = ngx_http_ssi_evaluate_string(r, ctx, value, 0); |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2333 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2334 if (rc != NGX_OK) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2335 return rc; |
509 | 2336 } |
2337 | |
611 | 2338 key = 0; |
2339 | |
2340 for (i = 0; i < name->len; i++) { | |
2341 name->data[i] = ngx_tolower(name->data[i]); | |
2342 key = ngx_hash(key, name->data[i]); | |
2343 } | |
2344 | |
2345 vv = ngx_http_ssi_get_variable(r, name, key); | |
553 | 2346 |
2347 if (vv) { | |
2348 *vv = *value; | |
2349 return NGX_OK; | |
2350 } | |
2351 | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2352 var = ngx_list_push(mctx->variables); |
553 | 2353 if (var == NULL) { |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2354 return NGX_ERROR; |
553 | 2355 } |
2356 | |
2357 var->name = *name; | |
611 | 2358 var->key = key; |
553 | 2359 var->value = *value; |
2360 | |
2361 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
2362 "set: \"%V\"=\"%V\"", name, value); | |
2363 | |
509 | 2364 return NGX_OK; |
2365 } | |
2366 | |
2367 | |
2368 static ngx_int_t | |
2369 ngx_http_ssi_if(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, | |
2370 ngx_str_t **params) | |
2371 { | |
553 | 2372 u_char *p, *last; |
2373 ngx_str_t *expr, left, right; | |
2374 ngx_int_t rc; | |
629 | 2375 ngx_uint_t negative, noregex, flags; |
509 | 2376 |
629 | 2377 if (ctx->command.len == 2) { |
2378 if (ctx->conditional) { | |
2379 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
2380 "the \"if\" command inside the \"if\" command"); | |
2381 return NGX_HTTP_SSI_ERROR; | |
2382 } | |
2383 } | |
2384 | |
2385 if (ctx->output_chosen) { | |
2386 ctx->output = 0; | |
2387 return NGX_OK; | |
2388 } | |
2389 | |
509 | 2390 expr = params[NGX_HTTP_SSI_IF_EXPR]; |
2391 | |
643 | 2392 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
2393 "ssi if expr=\"%V\"", expr); | |
2394 | |
553 | 2395 left.data = expr->data; |
551 | 2396 last = expr->data + expr->len; |
2397 | |
553 | 2398 for (p = left.data; p < last; p++) { |
551 | 2399 if (*p >= 'A' && *p <= 'Z') { |
2400 *p |= 0x20; | |
2401 continue; | |
2402 } | |
509 | 2403 |
553 | 2404 if ((*p >= 'a' && *p <= 'z') |
2405 || (*p >= '0' && *p <= '9') | |
573 | 2406 || *p == '$' || *p == '{' || *p == '}' || *p == '_' |
2407 || *p == '"' || *p == '\'') | |
553 | 2408 { |
551 | 2409 continue; |
2410 } | |
2411 | |
2412 break; | |
2413 } | |
2414 | |
553 | 2415 left.len = p - left.data; |
551 | 2416 |
2417 while (p < last && *p == ' ') { | |
2418 p++; | |
509 | 2419 } |
2420 | |
635 | 2421 flags = (p == last) ? NGX_HTTP_SSI_EXPR_TEST : 0; |
2422 | |
553 | 2423 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
2424 "left: \"%V\"", &left); | |
2425 | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2426 rc = ngx_http_ssi_evaluate_string(r, ctx, &left, flags); |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2427 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2428 if (rc != NGX_OK) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2429 return rc; |
509 | 2430 } |
2431 | |
553 | 2432 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
2433 "evaluted left: \"%V\"", &left); | |
2434 | |
551 | 2435 if (p == last) { |
553 | 2436 if (left.len) { |
551 | 2437 ctx->output = 1; |
629 | 2438 ctx->output_chosen = 1; |
551 | 2439 |
2440 } else { | |
2441 ctx->output = 0; | |
2442 } | |
2443 | |
629 | 2444 ctx->conditional = NGX_HTTP_SSI_COND_IF; |
2445 | |
551 | 2446 return NGX_OK; |
2447 } | |
2448 | |
2449 if (p < last && *p == '=') { | |
2450 negative = 0; | |
2451 p++; | |
2452 | |
2453 } else if (p + 1 < last && *p == '!' && *(p + 1) == '=') { | |
2454 negative = 1; | |
2455 p += 2; | |
2456 | |
2457 } else { | |
2458 goto invalid_expression; | |
2459 } | |
2460 | |
2461 while (p < last && *p == ' ') { | |
2462 p++; | |
2463 } | |
2464 | |
1190
99c56c0f514e
fix segfault or parsing error in '<!--# if expr="$var = /" -->'
Igor Sysoev <igor@sysoev.ru>
parents:
1169
diff
changeset
|
2465 if (p < last - 1 && *p == '/') { |
551 | 2466 if (*(last - 1) != '/') { |
2467 goto invalid_expression; | |
2468 } | |
2469 | |
2470 noregex = 0; | |
629 | 2471 flags = NGX_HTTP_SSI_ADD_ZERO; |
551 | 2472 last--; |
1025 | 2473 p++; |
551 | 2474 |
2475 } else { | |
2476 noregex = 1; | |
629 | 2477 flags = 0; |
2478 | |
2479 if (p < last - 1 && p[0] == '\\' && p[1] == '/') { | |
651 | 2480 p++; |
629 | 2481 } |
551 | 2482 } |
2483 | |
2484 right.len = last - p; | |
2485 right.data = p; | |
2486 | |
553 | 2487 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
2488 "right: \"%V\"", &right); | |
2489 | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2490 rc = ngx_http_ssi_evaluate_string(r, ctx, &right, flags); |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2491 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2492 if (rc != NGX_OK) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2493 return rc; |
551 | 2494 } |
2495 | |
553 | 2496 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
2497 "evaluted right: \"%V\"", &right); | |
551 | 2498 |
2499 if (noregex) { | |
2500 if (left.len != right.len) { | |
2501 rc = -1; | |
2502 | |
2503 } else { | |
2504 rc = ngx_strncmp(left.data, right.data, right.len); | |
2505 } | |
2506 | |
2507 } else { | |
2508 #if (NGX_PCRE) | |
1704
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1593
diff
changeset
|
2509 ngx_str_t err; |
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1593
diff
changeset
|
2510 ngx_regex_t *regex; |
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1593
diff
changeset
|
2511 u_char errstr[NGX_MAX_CONF_ERRSTR]; |
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1593
diff
changeset
|
2512 |
551 | 2513 err.len = NGX_MAX_CONF_ERRSTR; |
2514 err.data = errstr; | |
2515 | |
2516 right.data[right.len] = '\0'; | |
2517 | |
2518 regex = ngx_regex_compile(&right, 0, r->pool, &err); | |
2519 | |
2520 if (regex == NULL) { | |
2521 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "%s", err.data); | |
2522 return NGX_HTTP_SSI_ERROR; | |
2523 } | |
2524 | |
2525 rc = ngx_regex_exec(regex, &left, NULL, 0); | |
2526 | |
2527 if (rc != NGX_REGEX_NO_MATCHED && rc < 0) { | |
2528 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, | |
2529 ngx_regex_exec_n " failed: %d on \"%V\" using \"%V\"", | |
2530 rc, &left, &right); | |
2531 return NGX_HTTP_SSI_ERROR; | |
2532 } | |
2533 #else | |
2534 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, | |
2535 "the using of the regex \"%V\" in SSI " | |
2536 "requires PCRE library", &right); | |
2537 | |
2538 return NGX_HTTP_SSI_ERROR; | |
2539 #endif | |
2540 } | |
2541 | |
2542 if ((rc == 0 && !negative) || (rc != 0 && negative)) { | |
509 | 2543 ctx->output = 1; |
629 | 2544 ctx->output_chosen = 1; |
509 | 2545 |
2546 } else { | |
2547 ctx->output = 0; | |
2548 } | |
2549 | |
629 | 2550 ctx->conditional = NGX_HTTP_SSI_COND_IF; |
2551 | |
509 | 2552 return NGX_OK; |
551 | 2553 |
2554 invalid_expression: | |
2555 | |
2556 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
2557 "invalid expression in \"%V\"", expr); | |
2558 | |
2559 return NGX_HTTP_SSI_ERROR; | |
509 | 2560 } |
2561 | |
2562 | |
2563 static ngx_int_t | |
2564 ngx_http_ssi_else(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, | |
2565 ngx_str_t **params) | |
2566 { | |
643 | 2567 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
2568 "ssi else"); | |
2569 | |
629 | 2570 if (ctx->output_chosen) { |
2571 ctx->output = 0; | |
2572 } else { | |
2573 ctx->output = 1; | |
2574 } | |
2575 | |
2576 ctx->conditional = NGX_HTTP_SSI_COND_ELSE; | |
509 | 2577 |
2578 return NGX_OK; | |
2579 } | |
2580 | |
2581 | |
2582 static ngx_int_t | |
2583 ngx_http_ssi_endif(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, | |
2584 ngx_str_t **params) | |
2585 { | |
643 | 2586 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
2587 "ssi endif"); | |
2588 | |
509 | 2589 ctx->output = 1; |
629 | 2590 ctx->output_chosen = 0; |
2591 ctx->conditional = 0; | |
509 | 2592 |
2593 return NGX_OK; | |
2594 } | |
2595 | |
2596 | |
573 | 2597 static ngx_int_t |
667 | 2598 ngx_http_ssi_block(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, |
2599 ngx_str_t **params) | |
2600 { | |
2601 ngx_http_ssi_ctx_t *mctx; | |
2602 ngx_http_ssi_block_t *bl; | |
2603 | |
2604 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
2605 "ssi block"); | |
2606 | |
2607 mctx = ngx_http_get_module_ctx(r->main, ngx_http_ssi_filter_module); | |
2608 | |
2609 if (mctx->blocks == NULL) { | |
2610 mctx->blocks = ngx_array_create(r->pool, 4, | |
2611 sizeof(ngx_http_ssi_block_t)); | |
2612 if (mctx->blocks == NULL) { | |
2613 return NGX_HTTP_SSI_ERROR; | |
2614 } | |
2615 } | |
2616 | |
2617 bl = ngx_array_push(mctx->blocks); | |
2618 if (bl == NULL) { | |
2619 return NGX_HTTP_SSI_ERROR; | |
2620 } | |
2621 | |
2622 bl->name = *params[NGX_HTTP_SSI_BLOCK_NAME]; | |
2623 bl->bufs = NULL; | |
2624 bl->count = 0; | |
2625 | |
2626 ctx->output = 0; | |
2627 ctx->block = 1; | |
2628 | |
2629 return NGX_OK; | |
2630 } | |
2631 | |
2632 | |
2633 static ngx_int_t | |
2634 ngx_http_ssi_endblock(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, | |
2635 ngx_str_t **params) | |
2636 { | |
2637 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
2638 "ssi endblock"); | |
2639 | |
2640 ctx->output = 1; | |
2641 ctx->block = 0; | |
2642 | |
2643 return NGX_OK; | |
2644 } | |
2645 | |
2646 | |
2647 static ngx_int_t | |
573 | 2648 ngx_http_ssi_date_gmt_local_variable(ngx_http_request_t *r, |
2649 ngx_http_variable_value_t *v, uintptr_t gmt) | |
509 | 2650 { |
573 | 2651 ngx_http_ssi_ctx_t *ctx; |
2652 ngx_time_t *tp; | |
2653 struct tm tm; | |
2654 char buf[NGX_HTTP_SSI_DATE_LEN]; | |
2655 | |
577 | 2656 v->valid = 1; |
1565 | 2657 v->no_cacheable = 0; |
573 | 2658 v->not_found = 0; |
509 | 2659 |
563 | 2660 tp = ngx_timeofday(); |
2661 | |
509 | 2662 ctx = ngx_http_get_module_ctx(r, ngx_http_ssi_filter_module); |
2663 | |
1566
f00b905cb70b
fix segfault when $date_local or $date_gmt are used outside ssi module
Igor Sysoev <igor@sysoev.ru>
parents:
1565
diff
changeset
|
2664 if (ctx == NULL |
f00b905cb70b
fix segfault when $date_local or $date_gmt are used outside ssi module
Igor Sysoev <igor@sysoev.ru>
parents:
1565
diff
changeset
|
2665 || (ctx->timefmt.len == sizeof("%s") - 1 |
f00b905cb70b
fix segfault when $date_local or $date_gmt are used outside ssi module
Igor Sysoev <igor@sysoev.ru>
parents:
1565
diff
changeset
|
2666 && ctx->timefmt.data[0] == '%' && ctx->timefmt.data[1] == 's')) |
509 | 2667 { |
573 | 2668 v->data = ngx_palloc(r->pool, NGX_TIME_T_LEN); |
2669 if (v->data == NULL) { | |
2670 return NGX_ERROR; | |
509 | 2671 } |
2672 | |
573 | 2673 v->len = ngx_sprintf(v->data, "%T", tp->sec + (gmt ? 0 : tp->gmtoff)) |
2674 - v->data; | |
657 | 2675 |
573 | 2676 return NGX_OK; |
509 | 2677 } |
2678 | |
2679 if (gmt) { | |
563 | 2680 ngx_libc_gmtime(tp->sec, &tm); |
509 | 2681 } else { |
563 | 2682 ngx_libc_localtime(tp->sec, &tm); |
509 | 2683 } |
2684 | |
573 | 2685 v->len = strftime(buf, NGX_HTTP_SSI_DATE_LEN, |
2686 (char *) ctx->timefmt.data, &tm); | |
2687 if (v->len == 0) { | |
2688 return NGX_ERROR; | |
509 | 2689 } |
2690 | |
573 | 2691 v->data = ngx_palloc(r->pool, v->len); |
2692 if (v->data == NULL) { | |
2693 return NGX_ERROR; | |
509 | 2694 } |
2695 | |
573 | 2696 ngx_memcpy(v->data, buf, v->len); |
2697 | |
2698 return NGX_OK; | |
509 | 2699 } |
2700 | |
2701 | |
527 | 2702 static char * |
2703 ngx_http_ssi_types(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
2704 { | |
597 | 2705 ngx_http_ssi_loc_conf_t *slcf = conf; |
527 | 2706 |
2707 ngx_str_t *value, *type; | |
2708 ngx_uint_t i; | |
2709 | |
597 | 2710 if (slcf->types == NULL) { |
2711 slcf->types = ngx_array_create(cf->pool, 4, sizeof(ngx_str_t)); | |
2712 if (slcf->types == NULL) { | |
527 | 2713 return NGX_CONF_ERROR; |
2714 } | |
2715 | |
597 | 2716 type = ngx_array_push(slcf->types); |
527 | 2717 if (type == NULL) { |
2718 return NGX_CONF_ERROR; | |
2719 } | |
2720 | |
2721 type->len = sizeof("text/html") - 1; | |
2722 type->data = (u_char *) "text/html"; | |
2723 } | |
2724 | |
2725 value = cf->args->elts; | |
2726 | |
2727 for (i = 1; i < cf->args->nelts; i++) { | |
2728 | |
2729 if (ngx_strcmp(value[i].data, "text/html") == 0) { | |
2730 continue; | |
2731 } | |
2732 | |
597 | 2733 type = ngx_array_push(slcf->types); |
527 | 2734 if (type == NULL) { |
2735 return NGX_CONF_ERROR; | |
2736 } | |
2737 | |
2738 type->len = value[i].len; | |
2739 | |
2740 type->data = ngx_palloc(cf->pool, type->len + 1); | |
2741 if (type->data == NULL) { | |
2742 return NGX_CONF_ERROR; | |
2743 } | |
2744 | |
2745 ngx_cpystrn(type->data, value[i].data, type->len + 1); | |
2746 } | |
2747 | |
2748 return NGX_CONF_OK; | |
2749 } | |
2750 | |
2751 | |
509 | 2752 static ngx_int_t |
597 | 2753 ngx_http_ssi_preconfiguration(ngx_conf_t *cf) |
509 | 2754 { |
597 | 2755 ngx_int_t rc; |
2756 ngx_http_variable_t *var, *v; | |
2757 ngx_http_ssi_command_t *cmd; | |
2758 ngx_http_ssi_main_conf_t *smcf; | |
509 | 2759 |
2760 for (v = ngx_http_ssi_vars; v->name.len; v++) { | |
2761 var = ngx_http_add_variable(cf, &v->name, v->flags); | |
2762 if (var == NULL) { | |
2763 return NGX_ERROR; | |
2764 } | |
2765 | |
637 | 2766 var->get_handler = v->get_handler; |
509 | 2767 var->data = v->data; |
2768 } | |
2769 | |
597 | 2770 smcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_ssi_filter_module); |
2771 | |
2772 for (cmd = ngx_http_ssi_commands; cmd->name.len; cmd++) { | |
2773 rc = ngx_hash_add_key(&smcf->commands, &cmd->name, cmd, | |
2774 NGX_HASH_READONLY_KEY); | |
2775 | |
2776 if (rc == NGX_OK) { | |
2777 continue; | |
2778 } | |
2779 | |
2780 if (rc == NGX_BUSY) { | |
2781 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
2782 "conflicting SSI command \"%V\"", &cmd->name); | |
2783 } | |
2784 | |
2785 return NGX_ERROR; | |
2786 } | |
2787 | |
577 | 2788 return NGX_OK; |
509 | 2789 } |
2790 | |
2791 | |
497 | 2792 static void * |
597 | 2793 ngx_http_ssi_create_main_conf(ngx_conf_t *cf) |
2794 { | |
2795 ngx_http_ssi_main_conf_t *smcf; | |
2796 | |
2797 smcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_ssi_main_conf_t)); | |
2798 if (smcf == NULL) { | |
2799 return NGX_CONF_ERROR; | |
2800 } | |
2801 | |
2802 smcf->commands.pool = cf->pool; | |
2803 smcf->commands.temp_pool = cf->temp_pool; | |
2804 | |
2805 if (ngx_hash_keys_array_init(&smcf->commands, NGX_HASH_SMALL) != NGX_OK) { | |
2806 return NGX_CONF_ERROR; | |
2807 } | |
2808 | |
2809 return smcf; | |
2810 } | |
2811 | |
2812 | |
2813 static char * | |
2814 ngx_http_ssi_init_main_conf(ngx_conf_t *cf, void *conf) | |
2815 { | |
2816 ngx_http_ssi_main_conf_t *smcf = conf; | |
2817 | |
2818 ngx_hash_init_t hash; | |
2819 | |
2820 hash.hash = &smcf->hash; | |
2821 hash.key = ngx_hash_key; | |
2822 hash.max_size = 1024; | |
2823 hash.bucket_size = ngx_cacheline_size; | |
2824 hash.name = "ssi_command_hash"; | |
2825 hash.pool = cf->pool; | |
2826 hash.temp_pool = NULL; | |
2827 | |
2828 if (ngx_hash_init(&hash, smcf->commands.keys.elts, | |
2829 smcf->commands.keys.nelts) | |
2830 != NGX_OK) | |
2831 { | |
2832 return NGX_CONF_ERROR; | |
2833 } | |
2834 | |
2835 return NGX_CONF_OK; | |
2836 } | |
2837 | |
2838 | |
2839 static void * | |
1169 | 2840 ngx_http_ssi_create_loc_conf(ngx_conf_t *cf) |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
2841 { |
597 | 2842 ngx_http_ssi_loc_conf_t *slcf; |
2843 | |
2844 slcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_ssi_loc_conf_t)); | |
2845 if (slcf == NULL) { | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
2846 return NGX_CONF_ERROR; |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
2847 } |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
2848 |
527 | 2849 /* |
2850 * set by ngx_pcalloc(): | |
2851 * | |
2852 * conf->types = NULL; | |
2853 */ | |
2854 | |
597 | 2855 slcf->enable = NGX_CONF_UNSET; |
2856 slcf->silent_errors = NGX_CONF_UNSET; | |
2857 slcf->ignore_recycled_buffers = NGX_CONF_UNSET; | |
2858 | |
2859 slcf->min_file_chunk = NGX_CONF_UNSET_SIZE; | |
2860 slcf->value_len = NGX_CONF_UNSET_SIZE; | |
2861 | |
2862 return slcf; | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
2863 } |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
2864 |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
2865 |
497 | 2866 static char * |
1169 | 2867 ngx_http_ssi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
2868 { |
597 | 2869 ngx_http_ssi_loc_conf_t *prev = parent; |
2870 ngx_http_ssi_loc_conf_t *conf = child; | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
2871 |
527 | 2872 ngx_str_t *type; |
2873 | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
2874 ngx_conf_merge_value(conf->enable, prev->enable, 0); |
497 | 2875 ngx_conf_merge_value(conf->silent_errors, prev->silent_errors, 0); |
509 | 2876 ngx_conf_merge_value(conf->ignore_recycled_buffers, |
2877 prev->ignore_recycled_buffers, 0); | |
497 | 2878 |
2879 ngx_conf_merge_size_value(conf->min_file_chunk, prev->min_file_chunk, 1024); | |
241
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
2880 ngx_conf_merge_size_value(conf->value_len, prev->value_len, 256); |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
2881 |
527 | 2882 if (conf->types == NULL) { |
2883 if (prev->types == NULL) { | |
2884 conf->types = ngx_array_create(cf->pool, 1, sizeof(ngx_str_t)); | |
2885 if (conf->types == NULL) { | |
2886 return NGX_CONF_ERROR; | |
2887 } | |
2888 | |
2889 type = ngx_array_push(conf->types); | |
2890 if (type == NULL) { | |
2891 return NGX_CONF_ERROR; | |
2892 } | |
2893 | |
2894 type->len = sizeof("text/html") - 1; | |
2895 type->data = (u_char *) "text/html"; | |
2896 | |
2897 } else { | |
2898 conf->types = prev->types; | |
2899 } | |
2900 } | |
2901 | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
2902 return NGX_CONF_OK; |
15
cbb38b60495c
nginx-0.0.1-2002-09-18-20:32:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
14
diff
changeset
|
2903 } |
14
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
2904 |
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
2905 |
497 | 2906 static ngx_int_t |
681 | 2907 ngx_http_ssi_filter_init(ngx_conf_t *cf) |
125
885ffb8cc32a
nginx-0.0.1-2003-08-06-09:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
16
diff
changeset
|
2908 { |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
2909 ngx_http_next_header_filter = ngx_http_top_header_filter; |
125
885ffb8cc32a
nginx-0.0.1-2003-08-06-09:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
16
diff
changeset
|
2910 ngx_http_top_header_filter = ngx_http_ssi_header_filter; |
14
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
2911 |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
2912 ngx_http_next_body_filter = ngx_http_top_body_filter; |
125
885ffb8cc32a
nginx-0.0.1-2003-08-06-09:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
16
diff
changeset
|
2913 ngx_http_top_body_filter = ngx_http_ssi_body_filter; |
14
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
2914 |
125
885ffb8cc32a
nginx-0.0.1-2003-08-06-09:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
16
diff
changeset
|
2915 return NGX_OK; |
14
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
2916 } |