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