nginx 第3方模块echo代码阅读的问题总结
typedef struct { /* elements of the following arrays are of type * ngx_http_echo_cmd_t */ ngx_array_t *handler_cmds;——》保存的是需要处理的echo命令的集合,是ngx_http_echo_cmd_t的结构体组成 ngx_array_t *before_body_cmds; ngx_array_t *after_body_cmds; unsigned seen_leading_output; } ngx_http_echo_loc_conf_t;
1 typedef struct { 2 ngx_http_echo_opcode_t opcode;——》命令执行的操作类型 3 4 /* each argument is of type echo_arg_template_t: */ 5 ngx_array_t *args;——》命令携带的参数 6 } ngx_http_echo_cmd_t;
echo私有的环境变量的设置
ngx_http_set_ctx(r, ctx, ngx_http_echo_module);设置在当前请求中ngx_http_echo_module的环境变量ctx;
ngx_http_get_module_ctx(r, ngx_http_echo_module);获取在当前的请求中ngx_http_echo_module的环境变量;