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