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