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