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