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