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