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