12
12
#include <ngx_log.h>
14
14
/* config init handler */
15
static void * ngx_http_echo_create_conf(ngx_conf_t *cf);
15
static void * ngx_http_echo_create_loc_conf(ngx_conf_t *cf);
16
static char * ngx_http_echo_merge_loc_conf(ngx_conf_t *cf, void *parent,
17
19
/* config directive handlers */
18
20
static char * ngx_http_echo_echo(ngx_conf_t *cf, ngx_command_t *cmd,
21
22
static char * ngx_http_echo_echo_request_body(ngx_conf_t *cf,
22
23
ngx_command_t *cmd, void *conf);
24
24
static char * ngx_http_echo_echo_sleep(ngx_conf_t *cf, ngx_command_t *cmd,
27
26
static char * ngx_http_echo_echo_flush(ngx_conf_t *cf, ngx_command_t *cmd,
30
28
static char * ngx_http_echo_echo_blocking_sleep(ngx_conf_t *cf,
31
29
ngx_command_t *cmd, void *conf);
33
30
static char * ngx_http_echo_echo_reset_timer(ngx_conf_t *cf,
34
31
ngx_command_t *cmd, void *conf);
36
32
static char * ngx_http_echo_echo_before_body(ngx_conf_t *cf,
37
33
ngx_command_t *cmd, void *conf);
39
34
static char * ngx_http_echo_echo_after_body(ngx_conf_t *cf,
40
35
ngx_command_t *cmd, void *conf);
42
36
static char * ngx_http_echo_echo_location_async(ngx_conf_t *cf,
43
37
ngx_command_t *cmd, void *conf);
45
38
static char * ngx_http_echo_echo_location(ngx_conf_t *cf,
46
39
ngx_command_t *cmd, void *conf);
48
40
static char * ngx_http_echo_echo_subrequest_async(ngx_conf_t *cf,
49
41
ngx_command_t *cmd, void *conf);
51
42
static char * ngx_http_echo_echo_subrequest(ngx_conf_t *cf,
52
43
ngx_command_t *cmd, void *conf);
54
44
static char * ngx_http_echo_echo_duplicate(ngx_conf_t *cf,
55
45
ngx_command_t *cmd, void *conf);
57
46
static char * ngx_http_echo_echo_read_request_body(ngx_conf_t *cf,
58
47
ngx_command_t *cmd, void *conf);
60
48
static char * ngx_http_echo_echo_foreach_split(ngx_conf_t *cf,
61
49
ngx_command_t *cmd, void *conf);
63
50
static char * ngx_http_echo_echo_end(ngx_conf_t *cf,
64
51
ngx_command_t *cmd, void *conf);
66
52
static char * ngx_http_echo_echo_abort_parent(ngx_conf_t *cf,
67
53
ngx_command_t *cmd, void *conf);
69
54
static char * ngx_http_echo_echo_exec(ngx_conf_t *cf,
70
55
ngx_command_t *cmd, void *conf);
72
56
static char * ngx_http_echo_helper(ngx_http_echo_opcode_t opcode,
73
57
ngx_http_echo_cmd_category_t cat,
74
ngx_conf_t *cf, ngx_command_t *cmd, void* conf);
58
ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
77
61
static ngx_http_module_t ngx_http_echo_module_ctx = {
78
/* TODO we could add our own variables here... */
79
ngx_http_echo_handler_init, /* preconfiguration */
80
ngx_http_echo_filter_init, /* postconfiguration */
62
ngx_http_echo_handler_init, /* preconfiguration */
63
ngx_http_echo_filter_init, /* postconfiguration */
82
65
NULL, /* create main configuration */
83
66
NULL, /* init main configuration */
218
201
offsetof(ngx_http_echo_loc_conf_t, handler_cmds),
204
{ ngx_string("echo_status"),
205
NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF|NGX_CONF_TAKE1,
206
ngx_conf_set_num_slot,
207
NGX_HTTP_LOC_CONF_OFFSET,
208
offsetof(ngx_http_echo_loc_conf_t, status),
225
215
ngx_module_t ngx_http_echo_module = {
227
&ngx_http_echo_module_ctx, /* module context */
228
ngx_http_echo_commands, /* module directives */
217
&ngx_http_echo_module_ctx, /* module context */
218
ngx_http_echo_commands, /* module directives */
229
219
NGX_HTTP_MODULE, /* module type */
230
220
NULL, /* init master */
231
221
NULL, /* init module */
256
246
* conf->seen_trailing_output = 0
249
conf->status = NGX_CONF_UNSET;
256
ngx_http_echo_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
258
ngx_http_echo_loc_conf_t *prev = parent;
259
ngx_http_echo_loc_conf_t *conf = child;
261
if (conf->handler_cmds == NULL) {
262
conf->handler_cmds = prev->handler_cmds;
263
conf->seen_leading_output = prev->seen_leading_output;
266
if (conf->before_body_cmds == NULL) {
267
conf->before_body_cmds = prev->before_body_cmds;
270
if (conf->after_body_cmds == NULL) {
271
conf->after_body_cmds = prev->after_body_cmds;
274
ngx_conf_merge_value(conf->status, prev->status, 200);
264
281
ngx_http_echo_helper(ngx_http_echo_opcode_t opcode,
265
282
ngx_http_echo_cmd_category_t cat,
266
283
ngx_conf_t *cf, ngx_command_t *cmd, void* conf)
268
285
ngx_http_core_loc_conf_t *clcf;
269
/* ngx_http_echo_loc_conf_t *elcf = conf; */
270
286
ngx_array_t **args_ptr;
271
287
ngx_http_script_compile_t sc;
272
288
ngx_str_t *raw_args;