mirror of
https://github.com/nginx/nginx.git
synced 2026-08-31 09:06:25 +00:00
nginx-0.4.0-RELEASE import
*) Change in internal API: the HTTP modules initialization was moved
from the init module phase to the HTTP postconfiguration phase.
*) Change: now the request body is not read beforehand for the
ngx_http_perl_module: it's required to start the reading using the
$r->has_request_body method.
*) Feature: the ngx_http_perl_module supports the DECLINED return code.
*) Feature: the ngx_http_dav_module supports the incoming "Date" header
line for the PUT method.
*) Feature: the "ssi" directive is available inside the "if" block.
*) Bugfix: a segmentation fault occurred if there was an "index"
directive with variables and the first index name was without
variables; the bug had appeared in 0.1.29.
This commit is contained in:
parent
9cdd8a1cbc
commit
da173abde0
51 changed files with 1081 additions and 458 deletions
|
|
@ -29,7 +29,7 @@ static char *ngx_http_access_rule(ngx_conf_t *cf, ngx_command_t *cmd,
|
|||
static void *ngx_http_access_create_loc_conf(ngx_conf_t *cf);
|
||||
static char *ngx_http_access_merge_loc_conf(ngx_conf_t *cf,
|
||||
void *parent, void *child);
|
||||
static ngx_int_t ngx_http_access_init(ngx_cycle_t *cycle);
|
||||
static ngx_int_t ngx_http_access_init(ngx_conf_t *cf);
|
||||
|
||||
|
||||
static ngx_command_t ngx_http_access_commands[] = {
|
||||
|
|
@ -57,7 +57,7 @@ static ngx_command_t ngx_http_access_commands[] = {
|
|||
|
||||
static ngx_http_module_t ngx_http_access_module_ctx = {
|
||||
NULL, /* preconfiguration */
|
||||
NULL, /* postconfiguration */
|
||||
ngx_http_access_init, /* postconfiguration */
|
||||
|
||||
NULL, /* create main configuration */
|
||||
NULL, /* init main configuration */
|
||||
|
|
@ -76,7 +76,7 @@ ngx_module_t ngx_http_access_module = {
|
|||
ngx_http_access_commands, /* module directives */
|
||||
NGX_HTTP_MODULE, /* module type */
|
||||
NULL, /* init master */
|
||||
ngx_http_access_init, /* init module */
|
||||
NULL, /* init module */
|
||||
NULL, /* init process */
|
||||
NULL, /* init thread */
|
||||
NULL, /* exit thread */
|
||||
|
|
@ -215,12 +215,12 @@ ngx_http_access_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|
|||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_access_init(ngx_cycle_t *cycle)
|
||||
ngx_http_access_init(ngx_conf_t *cf)
|
||||
{
|
||||
ngx_http_handler_pt *h;
|
||||
ngx_http_core_main_conf_t *cmcf;
|
||||
|
||||
cmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module);
|
||||
cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
|
||||
|
||||
h = ngx_array_push(&cmcf->phases[NGX_HTTP_ACCESS_PHASE].handlers);
|
||||
if (h == NULL) {
|
||||
|
|
|
|||
|
|
@ -20,10 +20,10 @@ typedef struct {
|
|||
} ngx_http_addition_ctx_t;
|
||||
|
||||
|
||||
static ngx_int_t ngx_http_addition_filter_init(ngx_cycle_t *cycle);
|
||||
static void *ngx_http_addition_create_conf(ngx_conf_t *cf);
|
||||
static char *ngx_http_addition_merge_conf(ngx_conf_t *cf, void *parent,
|
||||
void *child);
|
||||
static ngx_int_t ngx_http_addition_filter_init(ngx_conf_t *cf);
|
||||
|
||||
|
||||
static ngx_command_t ngx_http_addition_commands[] = {
|
||||
|
|
@ -48,7 +48,7 @@ static ngx_command_t ngx_http_addition_commands[] = {
|
|||
|
||||
static ngx_http_module_t ngx_http_addition_filter_module_ctx = {
|
||||
NULL, /* preconfiguration */
|
||||
NULL, /* postconfiguration */
|
||||
ngx_http_addition_filter_init, /* postconfiguration */
|
||||
|
||||
NULL, /* create main configuration */
|
||||
NULL, /* init main configuration */
|
||||
|
|
@ -67,7 +67,7 @@ ngx_module_t ngx_http_addition_filter_module = {
|
|||
ngx_http_addition_commands, /* module directives */
|
||||
NGX_HTTP_MODULE, /* module type */
|
||||
NULL, /* init master */
|
||||
ngx_http_addition_filter_init, /* init module */
|
||||
NULL, /* init module */
|
||||
NULL, /* init process */
|
||||
NULL, /* init thread */
|
||||
NULL, /* exit thread */
|
||||
|
|
@ -178,7 +178,7 @@ ngx_http_addition_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_addition_filter_init(ngx_cycle_t *cycle)
|
||||
ngx_http_addition_filter_init(ngx_conf_t *cf)
|
||||
{
|
||||
ngx_http_next_header_filter = ngx_http_top_header_filter;
|
||||
ngx_http_top_header_filter = ngx_http_addition_header_filter;
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ static void ngx_http_auth_basic_close(ngx_file_t *file);
|
|||
static void *ngx_http_auth_basic_create_loc_conf(ngx_conf_t *cf);
|
||||
static char *ngx_http_auth_basic_merge_loc_conf(ngx_conf_t *cf,
|
||||
void *parent, void *child);
|
||||
static ngx_int_t ngx_http_auth_basic_init(ngx_cycle_t *cycle);
|
||||
static ngx_int_t ngx_http_auth_basic_init(ngx_conf_t *cf);
|
||||
static char *ngx_http_auth_basic(ngx_conf_t *cf, void *post, void *data);
|
||||
|
||||
|
||||
|
|
@ -62,7 +62,7 @@ static ngx_command_t ngx_http_auth_basic_commands[] = {
|
|||
|
||||
static ngx_http_module_t ngx_http_auth_basic_module_ctx = {
|
||||
NULL, /* preconfiguration */
|
||||
NULL, /* postconfiguration */
|
||||
ngx_http_auth_basic_init, /* postconfiguration */
|
||||
|
||||
NULL, /* create main configuration */
|
||||
NULL, /* init main configuration */
|
||||
|
|
@ -81,7 +81,7 @@ ngx_module_t ngx_http_auth_basic_module = {
|
|||
ngx_http_auth_basic_commands, /* module directives */
|
||||
NGX_HTTP_MODULE, /* module type */
|
||||
NULL, /* init master */
|
||||
ngx_http_auth_basic_init, /* init module */
|
||||
NULL, /* init module */
|
||||
NULL, /* init process */
|
||||
NULL, /* init thread */
|
||||
NULL, /* exit thread */
|
||||
|
|
@ -351,12 +351,12 @@ ngx_http_auth_basic_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|
|||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_auth_basic_init(ngx_cycle_t *cycle)
|
||||
ngx_http_auth_basic_init(ngx_conf_t *cf)
|
||||
{
|
||||
ngx_http_handler_pt *h;
|
||||
ngx_http_core_main_conf_t *cmcf;
|
||||
|
||||
cmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module);
|
||||
cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
|
||||
|
||||
h = ngx_array_push(&cmcf->phases[NGX_HTTP_ACCESS_PHASE].handlers);
|
||||
if (h == NULL) {
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ static int ngx_libc_cdecl ngx_http_autoindex_cmp_entries(const void *one,
|
|||
const void *two);
|
||||
static ngx_int_t ngx_http_autoindex_error(ngx_http_request_t *r,
|
||||
ngx_dir_t *dir, ngx_str_t *name);
|
||||
static ngx_int_t ngx_http_autoindex_init(ngx_cycle_t *cycle);
|
||||
static ngx_int_t ngx_http_autoindex_init(ngx_conf_t *cf);
|
||||
static void *ngx_http_autoindex_create_loc_conf(ngx_conf_t *cf);
|
||||
static char *ngx_http_autoindex_merge_loc_conf(ngx_conf_t *cf,
|
||||
void *parent, void *child);
|
||||
|
|
@ -83,7 +83,7 @@ static ngx_command_t ngx_http_autoindex_commands[] = {
|
|||
|
||||
static ngx_http_module_t ngx_http_autoindex_module_ctx = {
|
||||
NULL, /* preconfiguration */
|
||||
NULL, /* postconfiguration */
|
||||
ngx_http_autoindex_init, /* postconfiguration */
|
||||
|
||||
NULL, /* create main configuration */
|
||||
NULL, /* init main configuration */
|
||||
|
|
@ -102,7 +102,7 @@ ngx_module_t ngx_http_autoindex_module = {
|
|||
ngx_http_autoindex_commands, /* module directives */
|
||||
NGX_HTTP_MODULE, /* module type */
|
||||
NULL, /* init master */
|
||||
ngx_http_autoindex_init, /* init module */
|
||||
NULL, /* init module */
|
||||
NULL, /* init process */
|
||||
NULL, /* init thread */
|
||||
NULL, /* exit thread */
|
||||
|
|
@ -590,25 +590,6 @@ ngx_http_autoindex_error(ngx_http_request_t *r, ngx_dir_t *dir, ngx_str_t *name)
|
|||
}
|
||||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_autoindex_init(ngx_cycle_t *cycle)
|
||||
{
|
||||
ngx_http_handler_pt *h;
|
||||
ngx_http_core_main_conf_t *cmcf;
|
||||
|
||||
cmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module);
|
||||
|
||||
h = ngx_array_push(&cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers);
|
||||
if (h == NULL) {
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
*h = ngx_http_autoindex_handler;
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
|
||||
static void *
|
||||
ngx_http_autoindex_create_loc_conf(ngx_conf_t *cf)
|
||||
{
|
||||
|
|
@ -639,3 +620,22 @@ ngx_http_autoindex_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|
|||
|
||||
return NGX_CONF_OK;
|
||||
}
|
||||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_autoindex_init(ngx_conf_t *cf)
|
||||
{
|
||||
ngx_http_handler_pt *h;
|
||||
ngx_http_core_main_conf_t *cmcf;
|
||||
|
||||
cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
|
||||
|
||||
h = ngx_array_push(&cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers);
|
||||
if (h == NULL) {
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
*h = ngx_http_autoindex_handler;
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,8 +102,6 @@ static char *ngx_http_set_charset_slot(ngx_conf_t *cf, ngx_command_t *cmd,
|
|||
void *conf);
|
||||
static ngx_int_t ngx_http_add_charset(ngx_array_t *charsets, ngx_str_t *name);
|
||||
|
||||
static ngx_int_t ngx_http_charset_filter_init(ngx_cycle_t *cycle);
|
||||
|
||||
static void *ngx_http_charset_create_main_conf(ngx_conf_t *cf);
|
||||
static void *ngx_http_charset_create_loc_conf(ngx_conf_t *cf);
|
||||
static char *ngx_http_charset_merge_loc_conf(ngx_conf_t *cf,
|
||||
|
|
@ -169,7 +167,7 @@ ngx_module_t ngx_http_charset_filter_module = {
|
|||
ngx_http_charset_filter_commands, /* module directives */
|
||||
NGX_HTTP_MODULE, /* module type */
|
||||
NULL, /* init master */
|
||||
ngx_http_charset_filter_init, /* init module */
|
||||
NULL, /* init module */
|
||||
NULL, /* init process */
|
||||
NULL, /* init thread */
|
||||
NULL, /* exit thread */
|
||||
|
|
@ -1334,19 +1332,6 @@ ngx_http_add_charset(ngx_array_t *charsets, ngx_str_t *name)
|
|||
}
|
||||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_charset_filter_init(ngx_cycle_t *cycle)
|
||||
{
|
||||
ngx_http_next_header_filter = ngx_http_top_header_filter;
|
||||
ngx_http_top_header_filter = ngx_http_charset_header_filter;
|
||||
|
||||
ngx_http_next_body_filter = ngx_http_top_body_filter;
|
||||
ngx_http_top_body_filter = ngx_http_charset_body_filter;
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
|
||||
static void *
|
||||
ngx_http_charset_create_main_conf(ngx_conf_t *cf)
|
||||
{
|
||||
|
|
@ -1516,5 +1501,11 @@ ngx_http_charset_postconfiguration(ngx_conf_t *cf)
|
|||
dst[tables[t].src] = tables[t].dst2src;
|
||||
}
|
||||
|
||||
ngx_http_next_header_filter = ngx_http_top_header_filter;
|
||||
ngx_http_top_header_filter = ngx_http_charset_header_filter;
|
||||
|
||||
ngx_http_next_body_filter = ngx_http_top_body_filter;
|
||||
ngx_http_top_body_filter = ngx_http_charset_body_filter;
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@
|
|||
#include <ngx_http.h>
|
||||
|
||||
|
||||
static ngx_int_t ngx_http_chunked_filter_init(ngx_cycle_t *cycle);
|
||||
static ngx_int_t ngx_http_chunked_filter_init(ngx_conf_t *cf);
|
||||
|
||||
|
||||
static ngx_http_module_t ngx_http_chunked_filter_module_ctx = {
|
||||
NULL, /* preconfiguration */
|
||||
NULL, /* postconfiguration */
|
||||
ngx_http_chunked_filter_init, /* postconfiguration */
|
||||
|
||||
NULL, /* create main configuration */
|
||||
NULL, /* init main configuration */
|
||||
|
|
@ -33,7 +33,7 @@ ngx_module_t ngx_http_chunked_filter_module = {
|
|||
NULL, /* module directives */
|
||||
NGX_HTTP_MODULE, /* module type */
|
||||
NULL, /* init master */
|
||||
ngx_http_chunked_filter_init, /* init module */
|
||||
NULL, /* init module */
|
||||
NULL, /* init process */
|
||||
NULL, /* init thread */
|
||||
NULL, /* exit thread */
|
||||
|
|
@ -183,7 +183,7 @@ ngx_http_chunked_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_chunked_filter_init(ngx_cycle_t *cycle)
|
||||
ngx_http_chunked_filter_init(ngx_conf_t *cf)
|
||||
{
|
||||
ngx_http_next_header_filter = ngx_http_top_header_filter;
|
||||
ngx_http_top_header_filter = ngx_http_chunked_header_filter;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ static char *ngx_http_dav_access(ngx_conf_t *cf, ngx_command_t *cmd,
|
|||
static void *ngx_http_dav_create_loc_conf(ngx_conf_t *cf);
|
||||
static char *ngx_http_dav_merge_loc_conf(ngx_conf_t *cf,
|
||||
void *parent, void *child);
|
||||
static ngx_int_t ngx_http_dav_init(ngx_cycle_t *cycle);
|
||||
static ngx_int_t ngx_http_dav_init(ngx_conf_t *cf);
|
||||
|
||||
|
||||
static ngx_conf_bitmask_t ngx_http_dav_methods_mask[] = {
|
||||
|
|
@ -69,7 +69,7 @@ static ngx_command_t ngx_http_dav_commands[] = {
|
|||
|
||||
static ngx_http_module_t ngx_http_dav_module_ctx = {
|
||||
NULL, /* preconfiguration */
|
||||
NULL, /* postconfiguration */
|
||||
ngx_http_dav_init, /* postconfiguration */
|
||||
|
||||
NULL, /* create main configuration */
|
||||
NULL, /* init main configuration */
|
||||
|
|
@ -88,7 +88,7 @@ ngx_module_t ngx_http_dav_module = {
|
|||
ngx_http_dav_commands, /* module directives */
|
||||
NGX_HTTP_MODULE, /* module type */
|
||||
NULL, /* init master */
|
||||
ngx_http_dav_init, /* init module */
|
||||
NULL, /* init module */
|
||||
NULL, /* init process */
|
||||
NULL, /* init thread */
|
||||
NULL, /* exit thread */
|
||||
|
|
@ -245,6 +245,7 @@ ngx_http_dav_put_handler(ngx_http_request_t *r)
|
|||
{
|
||||
char *failed;
|
||||
u_char *name;
|
||||
time_t date;
|
||||
ngx_err_t err;
|
||||
ngx_str_t *temp, path;
|
||||
ngx_uint_t status;
|
||||
|
|
@ -295,6 +296,24 @@ ngx_http_dav_put_handler(ngx_http_request_t *r)
|
|||
|
||||
#endif
|
||||
|
||||
if (r->headers_in.date) {
|
||||
date = ngx_http_parse_time(r->headers_in.date->value.data,
|
||||
r->headers_in.date->value.len);
|
||||
|
||||
if (date != NGX_ERROR) {
|
||||
if (ngx_set_file_time(temp->data,
|
||||
r->request_body->temp_file->file.fd, date)
|
||||
!= NGX_OK)
|
||||
{
|
||||
err = ngx_errno;
|
||||
failed = ngx_set_file_time_n;
|
||||
name = temp->data;
|
||||
|
||||
goto failed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
failed = ngx_rename_file_n;
|
||||
name = path.data;
|
||||
|
||||
|
|
@ -332,13 +351,10 @@ ngx_http_dav_put_handler(ngx_http_request_t *r)
|
|||
err = ngx_errno;
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
#endif
|
||||
|
||||
failed:
|
||||
|
||||
#endif
|
||||
|
||||
if (ngx_delete_file(temp->data) == NGX_FILE_ERROR) {
|
||||
ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno,
|
||||
ngx_delete_file_n " \"%s\" failed",
|
||||
|
|
@ -543,12 +559,12 @@ ngx_http_dav_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|
|||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_dav_init(ngx_cycle_t *cycle)
|
||||
ngx_http_dav_init(ngx_conf_t *cf)
|
||||
{
|
||||
ngx_http_handler_pt *h;
|
||||
ngx_http_core_main_conf_t *cmcf;
|
||||
|
||||
cmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module);
|
||||
cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
|
||||
|
||||
h = ngx_array_push(&cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers);
|
||||
if (h == NULL) {
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ static ngx_int_t ngx_http_gzip_add_variables(ngx_conf_t *cf);
|
|||
static ngx_int_t ngx_http_gzip_ratio_variable(ngx_http_request_t *r,
|
||||
ngx_http_variable_value_t *v, uintptr_t data);
|
||||
|
||||
static ngx_int_t ngx_http_gzip_filter_init(ngx_cycle_t *cycle);
|
||||
static ngx_int_t ngx_http_gzip_filter_init(ngx_conf_t *cf);
|
||||
static void *ngx_http_gzip_create_conf(ngx_conf_t *cf);
|
||||
static char *ngx_http_gzip_merge_conf(ngx_conf_t *cf,
|
||||
void *parent, void *child);
|
||||
|
|
@ -201,7 +201,7 @@ static ngx_command_t ngx_http_gzip_filter_commands[] = {
|
|||
|
||||
static ngx_http_module_t ngx_http_gzip_filter_module_ctx = {
|
||||
ngx_http_gzip_add_variables, /* preconfiguration */
|
||||
NULL, /* postconfiguration */
|
||||
ngx_http_gzip_filter_init, /* postconfiguration */
|
||||
|
||||
NULL, /* create main configuration */
|
||||
NULL, /* init main configuration */
|
||||
|
|
@ -220,7 +220,7 @@ ngx_module_t ngx_http_gzip_filter_module = {
|
|||
ngx_http_gzip_filter_commands, /* module directives */
|
||||
NGX_HTTP_MODULE, /* module type */
|
||||
NULL, /* init master */
|
||||
ngx_http_gzip_filter_init, /* init module */
|
||||
NULL, /* init module */
|
||||
NULL, /* init process */
|
||||
NULL, /* init thread */
|
||||
NULL, /* exit thread */
|
||||
|
|
@ -1030,19 +1030,6 @@ ngx_http_gzip_ratio_variable(ngx_http_request_t *r,
|
|||
}
|
||||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_gzip_filter_init(ngx_cycle_t *cycle)
|
||||
{
|
||||
ngx_http_next_header_filter = ngx_http_top_header_filter;
|
||||
ngx_http_top_header_filter = ngx_http_gzip_header_filter;
|
||||
|
||||
ngx_http_next_body_filter = ngx_http_top_body_filter;
|
||||
ngx_http_top_body_filter = ngx_http_gzip_body_filter;
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
|
||||
static void *
|
||||
ngx_http_gzip_create_conf(ngx_conf_t *cf)
|
||||
{
|
||||
|
|
@ -1123,6 +1110,19 @@ ngx_http_gzip_merge_conf(ngx_conf_t *cf, void *parent, void *child)
|
|||
}
|
||||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_gzip_filter_init(ngx_conf_t *cf)
|
||||
{
|
||||
ngx_http_next_header_filter = ngx_http_top_header_filter;
|
||||
ngx_http_top_header_filter = ngx_http_gzip_header_filter;
|
||||
|
||||
ngx_http_next_body_filter = ngx_http_top_body_filter;
|
||||
ngx_http_top_body_filter = ngx_http_gzip_body_filter;
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
ngx_http_gzip_types(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -28,10 +28,10 @@ typedef struct {
|
|||
#define NGX_HTTP_EXPIRES_EPOCH -2147483645
|
||||
|
||||
|
||||
static ngx_int_t ngx_http_headers_filter_init(ngx_cycle_t *cycle);
|
||||
static void *ngx_http_headers_create_conf(ngx_conf_t *cf);
|
||||
static char *ngx_http_headers_merge_conf(ngx_conf_t *cf,
|
||||
void *parent, void *child);
|
||||
static ngx_int_t ngx_http_headers_filter_init(ngx_conf_t *cf);
|
||||
static char *ngx_http_headers_expires(ngx_conf_t *cf, ngx_command_t *cmd,
|
||||
void *conf);
|
||||
static char *ngx_http_headers_add(ngx_conf_t *cf, ngx_command_t *cmd,
|
||||
|
|
@ -62,7 +62,7 @@ static ngx_command_t ngx_http_headers_filter_commands[] = {
|
|||
|
||||
static ngx_http_module_t ngx_http_headers_filter_module_ctx = {
|
||||
NULL, /* preconfiguration */
|
||||
NULL, /* postconfiguration */
|
||||
ngx_http_headers_filter_init, /* postconfiguration */
|
||||
|
||||
NULL, /* create main configuration */
|
||||
NULL, /* init main configuration */
|
||||
|
|
@ -81,7 +81,7 @@ ngx_module_t ngx_http_headers_filter_module = {
|
|||
ngx_http_headers_filter_commands, /* module directives */
|
||||
NGX_HTTP_MODULE, /* module type */
|
||||
NULL, /* init master */
|
||||
ngx_http_headers_filter_init, /* init module */
|
||||
NULL, /* init module */
|
||||
NULL, /* init process */
|
||||
NULL, /* init thread */
|
||||
NULL, /* exit thread */
|
||||
|
|
@ -274,16 +274,6 @@ ngx_http_headers_filter(ngx_http_request_t *r)
|
|||
}
|
||||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_headers_filter_init(ngx_cycle_t *cycle)
|
||||
{
|
||||
ngx_http_next_header_filter = ngx_http_top_header_filter;
|
||||
ngx_http_top_header_filter = ngx_http_headers_filter;
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
|
||||
static void *
|
||||
ngx_http_headers_create_conf(ngx_conf_t *cf)
|
||||
{
|
||||
|
|
@ -331,6 +321,16 @@ ngx_http_headers_merge_conf(ngx_conf_t *cf, void *parent, void *child)
|
|||
}
|
||||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_headers_filter_init(ngx_conf_t *cf)
|
||||
{
|
||||
ngx_http_next_header_filter = ngx_http_top_header_filter;
|
||||
ngx_http_top_header_filter = ngx_http_headers_filter;
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
ngx_http_headers_expires(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ static ngx_int_t ngx_http_index_test_dir(ngx_http_request_t *r,
|
|||
static ngx_int_t ngx_http_index_error(ngx_http_request_t *r,
|
||||
ngx_http_index_ctx_t *ctx, ngx_err_t err);
|
||||
|
||||
static ngx_int_t ngx_http_index_init(ngx_cycle_t *cycle);
|
||||
static ngx_int_t ngx_http_index_init(ngx_conf_t *cf);
|
||||
static void *ngx_http_index_create_loc_conf(ngx_conf_t *cf);
|
||||
static char *ngx_http_index_merge_loc_conf(ngx_conf_t *cf,
|
||||
void *parent, void *child);
|
||||
|
|
@ -74,7 +74,7 @@ static ngx_command_t ngx_http_index_commands[] = {
|
|||
|
||||
static ngx_http_module_t ngx_http_index_module_ctx = {
|
||||
NULL, /* preconfiguration */
|
||||
NULL, /* postconfiguration */
|
||||
ngx_http_index_init, /* postconfiguration */
|
||||
|
||||
NULL, /* create main configuration */
|
||||
NULL, /* init main configuration */
|
||||
|
|
@ -93,7 +93,7 @@ ngx_module_t ngx_http_index_module = {
|
|||
ngx_http_index_commands, /* module directives */
|
||||
NGX_HTTP_MODULE, /* module type */
|
||||
NULL, /* init master */
|
||||
ngx_http_index_init, /* init module */
|
||||
NULL, /* init module */
|
||||
NULL, /* init process */
|
||||
NULL, /* init thread */
|
||||
NULL, /* exit thread */
|
||||
|
|
@ -198,7 +198,7 @@ ngx_http_index_handler(ngx_http_request_t *r)
|
|||
len += 16;
|
||||
}
|
||||
|
||||
if (len > ctx->path.len) {
|
||||
if (len > (size_t) (ctx->path.data + ctx->path.len - ctx->index.data)) {
|
||||
|
||||
last = ngx_http_map_uri_to_path(r, &ctx->path, len);
|
||||
if (last == NULL) {
|
||||
|
|
@ -378,7 +378,7 @@ ngx_http_index_create_loc_conf(ngx_conf_t *cf)
|
|||
}
|
||||
|
||||
conf->indices = NULL;
|
||||
conf->max_index_len = 1;
|
||||
conf->max_index_len = 0;
|
||||
|
||||
return conf;
|
||||
}
|
||||
|
|
@ -422,6 +422,25 @@ ngx_http_index_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|
|||
}
|
||||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_index_init(ngx_conf_t *cf)
|
||||
{
|
||||
ngx_http_handler_pt *h;
|
||||
ngx_http_core_main_conf_t *cmcf;
|
||||
|
||||
cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
|
||||
|
||||
h = ngx_array_push(&cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers);
|
||||
if (h == NULL) {
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
*h = ngx_http_index_handler;
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
|
||||
/* TODO: warn about duplicate indices */
|
||||
|
||||
static char *
|
||||
|
|
@ -429,8 +448,8 @@ ngx_http_index_set_index(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||
{
|
||||
ngx_http_index_loc_conf_t *ilcf = conf;
|
||||
|
||||
ngx_uint_t i, n;
|
||||
ngx_str_t *value;
|
||||
ngx_uint_t i, n;
|
||||
ngx_http_index_t *index;
|
||||
ngx_http_script_compile_t sc;
|
||||
|
||||
|
|
@ -471,9 +490,7 @@ ngx_http_index_set_index(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||
n = ngx_http_script_variables_count(&value[i]);
|
||||
|
||||
if (n == 0) {
|
||||
if (ilcf->max_index_len != 0
|
||||
&& ilcf->max_index_len < index->name.len)
|
||||
{
|
||||
if (ilcf->max_index_len < index->name.len) {
|
||||
ilcf->max_index_len = index->name.len;
|
||||
}
|
||||
|
||||
|
|
@ -496,28 +513,7 @@ ngx_http_index_set_index(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||
if (ngx_http_script_compile(&sc) != NGX_OK) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
ilcf->max_index_len = 0;
|
||||
}
|
||||
|
||||
return NGX_CONF_OK;
|
||||
}
|
||||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_index_init(ngx_cycle_t *cycle)
|
||||
{
|
||||
ngx_http_handler_pt *h;
|
||||
ngx_http_core_main_conf_t *cmcf;
|
||||
|
||||
cmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module);
|
||||
|
||||
h = ngx_array_push(&cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers);
|
||||
if (h == NULL) {
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
*h = ngx_http_index_handler;
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,12 +10,12 @@
|
|||
|
||||
|
||||
|
||||
static ngx_int_t ngx_http_not_modified_filter_init(ngx_cycle_t *cycle);
|
||||
static ngx_int_t ngx_http_not_modified_filter_init(ngx_conf_t *cf);
|
||||
|
||||
|
||||
static ngx_http_module_t ngx_http_not_modified_filter_module_ctx = {
|
||||
NULL, /* preconfiguration */
|
||||
NULL, /* postconfiguration */
|
||||
ngx_http_not_modified_filter_init, /* postconfiguration */
|
||||
|
||||
NULL, /* create main configuration */
|
||||
NULL, /* init main configuration */
|
||||
|
|
@ -34,7 +34,7 @@ ngx_module_t ngx_http_not_modified_filter_module = {
|
|||
NULL, /* module directives */
|
||||
NGX_HTTP_MODULE, /* module type */
|
||||
NULL, /* init master */
|
||||
ngx_http_not_modified_filter_init, /* init module */
|
||||
NULL, /* init module */
|
||||
NULL, /* init process */
|
||||
NULL, /* init thread */
|
||||
NULL, /* exit thread */
|
||||
|
|
@ -47,7 +47,8 @@ ngx_module_t ngx_http_not_modified_filter_module = {
|
|||
static ngx_http_output_header_filter_pt ngx_http_next_header_filter;
|
||||
|
||||
|
||||
static ngx_int_t ngx_http_not_modified_header_filter(ngx_http_request_t *r)
|
||||
static
|
||||
ngx_int_t ngx_http_not_modified_header_filter(ngx_http_request_t *r)
|
||||
{
|
||||
time_t ims;
|
||||
|
||||
|
|
@ -80,7 +81,8 @@ static ngx_int_t ngx_http_not_modified_header_filter(ngx_http_request_t *r)
|
|||
}
|
||||
|
||||
|
||||
static ngx_int_t ngx_http_not_modified_filter_init(ngx_cycle_t *cycle)
|
||||
static
|
||||
ngx_int_t ngx_http_not_modified_filter_init(ngx_conf_t *cf)
|
||||
{
|
||||
ngx_http_next_header_filter = ngx_http_top_header_filter;
|
||||
ngx_http_top_header_filter = ngx_http_not_modified_header_filter;
|
||||
|
|
|
|||
|
|
@ -49,13 +49,13 @@ typedef struct {
|
|||
} ngx_http_range_filter_ctx_t;
|
||||
|
||||
|
||||
static ngx_int_t ngx_http_range_header_filter_init(ngx_cycle_t *cycle);
|
||||
static ngx_int_t ngx_http_range_body_filter_init(ngx_cycle_t *cycle);
|
||||
static ngx_int_t ngx_http_range_header_filter_init(ngx_conf_t *cf);
|
||||
static ngx_int_t ngx_http_range_body_filter_init(ngx_conf_t *cf);
|
||||
|
||||
|
||||
static ngx_http_module_t ngx_http_range_header_filter_module_ctx = {
|
||||
NULL, /* preconfiguration */
|
||||
NULL, /* postconfiguration */
|
||||
ngx_http_range_header_filter_init, /* postconfiguration */
|
||||
|
||||
NULL, /* create main configuration */
|
||||
NULL, /* init main configuration */
|
||||
|
|
@ -74,7 +74,7 @@ ngx_module_t ngx_http_range_header_filter_module = {
|
|||
NULL, /* module directives */
|
||||
NGX_HTTP_MODULE, /* module type */
|
||||
NULL, /* init master */
|
||||
ngx_http_range_header_filter_init, /* init module */
|
||||
NULL, /* init module */
|
||||
NULL, /* init process */
|
||||
NULL, /* init thread */
|
||||
NULL, /* exit thread */
|
||||
|
|
@ -86,7 +86,7 @@ ngx_module_t ngx_http_range_header_filter_module = {
|
|||
|
||||
static ngx_http_module_t ngx_http_range_body_filter_module_ctx = {
|
||||
NULL, /* preconfiguration */
|
||||
NULL, /* postconfiguration */
|
||||
ngx_http_range_body_filter_init, /* postconfiguration */
|
||||
|
||||
NULL, /* create main configuration */
|
||||
NULL, /* init main configuration */
|
||||
|
|
@ -105,7 +105,7 @@ ngx_module_t ngx_http_range_body_filter_module = {
|
|||
NULL, /* module directives */
|
||||
NGX_HTTP_MODULE, /* module type */
|
||||
NULL, /* init master */
|
||||
ngx_http_range_body_filter_init, /* init module */
|
||||
NULL, /* init module */
|
||||
NULL, /* init process */
|
||||
NULL, /* init thread */
|
||||
NULL, /* exit thread */
|
||||
|
|
@ -588,7 +588,7 @@ ngx_http_range_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_range_header_filter_init(ngx_cycle_t *cycle)
|
||||
ngx_http_range_header_filter_init(ngx_conf_t *cf)
|
||||
{
|
||||
ngx_http_next_header_filter = ngx_http_top_header_filter;
|
||||
ngx_http_top_header_filter = ngx_http_range_header_filter;
|
||||
|
|
@ -598,7 +598,7 @@ ngx_http_range_header_filter_init(ngx_cycle_t *cycle)
|
|||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_range_body_filter_init(ngx_cycle_t *cycle)
|
||||
ngx_http_range_body_filter_init(ngx_conf_t *cf)
|
||||
{
|
||||
ngx_http_next_body_filter = ngx_http_top_body_filter;
|
||||
ngx_http_top_body_filter = ngx_http_range_body_filter;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ static char *ngx_http_realip_from(ngx_conf_t *cf, ngx_command_t *cmd,
|
|||
static void *ngx_http_realip_create_loc_conf(ngx_conf_t *cf);
|
||||
static char *ngx_http_realip_merge_loc_conf(ngx_conf_t *cf,
|
||||
void *parent, void *child);
|
||||
static ngx_int_t ngx_http_realip_init(ngx_cycle_t *cycle);
|
||||
static ngx_int_t ngx_http_realip_init(ngx_conf_t *cf);
|
||||
|
||||
|
||||
static ngx_conf_enum_t ngx_http_realip_header[] = {
|
||||
|
|
@ -63,7 +63,7 @@ static ngx_command_t ngx_http_realip_commands[] = {
|
|||
|
||||
static ngx_http_module_t ngx_http_realip_module_ctx = {
|
||||
NULL, /* preconfiguration */
|
||||
NULL, /* postconfiguration */
|
||||
ngx_http_realip_init, /* postconfiguration */
|
||||
|
||||
NULL, /* create main configuration */
|
||||
NULL, /* init main configuration */
|
||||
|
|
@ -82,7 +82,7 @@ ngx_module_t ngx_http_realip_module = {
|
|||
ngx_http_realip_commands, /* module directives */
|
||||
NGX_HTTP_MODULE, /* module type */
|
||||
NULL, /* init master */
|
||||
ngx_http_realip_init, /* init module */
|
||||
NULL, /* init module */
|
||||
NULL, /* init process */
|
||||
NULL, /* init thread */
|
||||
NULL, /* exit thread */
|
||||
|
|
@ -250,12 +250,12 @@ ngx_http_realip_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|
|||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_realip_init(ngx_cycle_t *cycle)
|
||||
ngx_http_realip_init(ngx_conf_t *cf)
|
||||
{
|
||||
ngx_http_handler_pt *h;
|
||||
ngx_http_core_main_conf_t *cmcf;
|
||||
|
||||
cmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module);
|
||||
cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
|
||||
|
||||
h = ngx_array_push(&cmcf->phases[NGX_HTTP_POST_READ_PHASE].handlers);
|
||||
if (h == NULL) {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ typedef struct {
|
|||
static void *ngx_http_rewrite_create_loc_conf(ngx_conf_t *cf);
|
||||
static char *ngx_http_rewrite_merge_loc_conf(ngx_conf_t *cf,
|
||||
void *parent, void *child);
|
||||
static ngx_int_t ngx_http_rewrite_init(ngx_cycle_t *cycle);
|
||||
static ngx_int_t ngx_http_rewrite_init(ngx_conf_t *cf);
|
||||
static char *ngx_http_rewrite(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
|
||||
static char *ngx_http_rewrite_return(ngx_conf_t *cf, ngx_command_t *cmd,
|
||||
void *conf);
|
||||
|
|
@ -104,7 +104,7 @@ static ngx_command_t ngx_http_rewrite_commands[] = {
|
|||
|
||||
static ngx_http_module_t ngx_http_rewrite_module_ctx = {
|
||||
NULL, /* preconfiguration */
|
||||
NULL, /* postconfiguration */
|
||||
ngx_http_rewrite_init, /* postconfiguration */
|
||||
|
||||
NULL, /* create main configuration */
|
||||
NULL, /* init main configuration */
|
||||
|
|
@ -123,7 +123,7 @@ ngx_module_t ngx_http_rewrite_module = {
|
|||
ngx_http_rewrite_commands, /* module directives */
|
||||
NGX_HTTP_MODULE, /* module type */
|
||||
NULL, /* init master */
|
||||
ngx_http_rewrite_init, /* init module */
|
||||
NULL, /* init module */
|
||||
NULL, /* init process */
|
||||
NULL, /* init thread */
|
||||
NULL, /* exit thread */
|
||||
|
|
@ -267,12 +267,12 @@ ngx_http_rewrite_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|
|||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_rewrite_init(ngx_cycle_t *cycle)
|
||||
ngx_http_rewrite_init(ngx_conf_t *cf)
|
||||
{
|
||||
ngx_http_handler_pt *h;
|
||||
ngx_http_core_main_conf_t *cmcf;
|
||||
|
||||
cmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module);
|
||||
cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
|
||||
|
||||
h = ngx_array_push(&cmcf->phases[NGX_HTTP_SERVER_REWRITE_PHASE].handlers);
|
||||
if (h == NULL) {
|
||||
|
|
|
|||
|
|
@ -106,13 +106,14 @@ static char *ngx_http_ssi_init_main_conf(ngx_conf_t *cf, void *conf);
|
|||
static void *ngx_http_ssi_create_conf(ngx_conf_t *cf);
|
||||
static char *ngx_http_ssi_merge_conf(ngx_conf_t *cf,
|
||||
void *parent, void *child);
|
||||
static ngx_int_t ngx_http_ssi_filter_init(ngx_cycle_t *cycle);
|
||||
static ngx_int_t ngx_http_ssi_filter_init(ngx_conf_t *cf);
|
||||
|
||||
|
||||
static ngx_command_t ngx_http_ssi_filter_commands[] = {
|
||||
|
||||
{ ngx_string("ssi"),
|
||||
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
||||
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
|
||||
|NGX_CONF_FLAG,
|
||||
ngx_conf_set_flag_slot,
|
||||
NGX_HTTP_LOC_CONF_OFFSET,
|
||||
offsetof(ngx_http_ssi_loc_conf_t, enable),
|
||||
|
|
@ -160,7 +161,7 @@ static ngx_command_t ngx_http_ssi_filter_commands[] = {
|
|||
|
||||
static ngx_http_module_t ngx_http_ssi_filter_module_ctx = {
|
||||
ngx_http_ssi_preconfiguration, /* preconfiguration */
|
||||
NULL, /* postconfiguration */
|
||||
ngx_http_ssi_filter_init, /* postconfiguration */
|
||||
|
||||
ngx_http_ssi_create_main_conf, /* create main configuration */
|
||||
ngx_http_ssi_init_main_conf, /* init main configuration */
|
||||
|
|
@ -179,7 +180,7 @@ ngx_module_t ngx_http_ssi_filter_module = {
|
|||
ngx_http_ssi_filter_commands, /* module directives */
|
||||
NGX_HTTP_MODULE, /* module type */
|
||||
NULL, /* init master */
|
||||
ngx_http_ssi_filter_init, /* init module */
|
||||
NULL, /* init module */
|
||||
NULL, /* init process */
|
||||
NULL, /* init thread */
|
||||
NULL, /* exit thread */
|
||||
|
|
@ -2654,7 +2655,7 @@ ngx_http_ssi_merge_conf(ngx_conf_t *cf, void *parent, void *child)
|
|||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_ssi_filter_init(ngx_cycle_t *cycle)
|
||||
ngx_http_ssi_filter_init(ngx_conf_t *cf)
|
||||
{
|
||||
ngx_http_next_header_filter = ngx_http_top_header_filter;
|
||||
ngx_http_top_header_filter = ngx_http_ssi_header_filter;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ static ngx_int_t ngx_http_static_handler(ngx_http_request_t *r);
|
|||
static void *ngx_http_static_create_loc_conf(ngx_conf_t *cf);
|
||||
static char *ngx_http_static_merge_loc_conf(ngx_conf_t *cf,
|
||||
void *parent, void *child);
|
||||
static ngx_int_t ngx_http_static_init(ngx_cycle_t *cycle);
|
||||
static ngx_int_t ngx_http_static_init(ngx_conf_t *cf);
|
||||
|
||||
|
||||
static ngx_command_t ngx_http_static_commands[] = {
|
||||
|
|
@ -40,7 +40,7 @@ static ngx_command_t ngx_http_static_commands[] = {
|
|||
|
||||
ngx_http_module_t ngx_http_static_module_ctx = {
|
||||
NULL, /* preconfiguration */
|
||||
NULL, /* postconfiguration */
|
||||
ngx_http_static_init, /* postconfiguration */
|
||||
|
||||
NULL, /* create main configuration */
|
||||
NULL, /* init main configuration */
|
||||
|
|
@ -59,7 +59,7 @@ ngx_module_t ngx_http_static_module = {
|
|||
ngx_http_static_commands, /* module directives */
|
||||
NGX_HTTP_MODULE, /* module type */
|
||||
NULL, /* init master */
|
||||
ngx_http_static_init, /* init module */
|
||||
NULL, /* init module */
|
||||
NULL, /* init process */
|
||||
NULL, /* init thread */
|
||||
NULL, /* exit thread */
|
||||
|
|
@ -317,12 +317,12 @@ ngx_http_static_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|
|||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_static_init(ngx_cycle_t *cycle)
|
||||
ngx_http_static_init(ngx_conf_t *cf)
|
||||
{
|
||||
ngx_http_handler_pt *h;
|
||||
ngx_http_core_main_conf_t *cmcf;
|
||||
|
||||
cmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module);
|
||||
cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
|
||||
|
||||
h = ngx_array_push(&cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers);
|
||||
if (h == NULL) {
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ static ngx_int_t ngx_http_userid_add_variables(ngx_conf_t *cf);
|
|||
static ngx_int_t ngx_http_userid_variable(ngx_http_request_t *r,
|
||||
ngx_http_variable_value_t *v, uintptr_t data);
|
||||
|
||||
static ngx_int_t ngx_http_userid_init(ngx_cycle_t *cycle);
|
||||
static ngx_int_t ngx_http_userid_init(ngx_conf_t *cf);
|
||||
static void *ngx_http_userid_create_conf(ngx_conf_t *cf);
|
||||
static char *ngx_http_userid_merge_conf(ngx_conf_t *cf, void *parent,
|
||||
void *child);
|
||||
|
|
@ -162,7 +162,7 @@ static ngx_command_t ngx_http_userid_commands[] = {
|
|||
|
||||
static ngx_http_module_t ngx_http_userid_filter_module_ctx = {
|
||||
ngx_http_userid_add_variables, /* preconfiguration */
|
||||
NULL, /* postconfiguration */
|
||||
ngx_http_userid_init, /* postconfiguration */
|
||||
|
||||
NULL, /* create main configuration */
|
||||
NULL, /* init main configuration */
|
||||
|
|
@ -181,7 +181,7 @@ ngx_module_t ngx_http_userid_filter_module = {
|
|||
ngx_http_userid_commands, /* module directives */
|
||||
NGX_HTTP_MODULE, /* module type */
|
||||
NULL, /* init master */
|
||||
ngx_http_userid_init, /* init module */
|
||||
NULL, /* init module */
|
||||
NULL, /* init process */
|
||||
NULL, /* init thread */
|
||||
NULL, /* exit thread */
|
||||
|
|
@ -622,16 +622,6 @@ ngx_http_userid_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v,
|
|||
}
|
||||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_userid_init(ngx_cycle_t *cycle)
|
||||
{
|
||||
ngx_http_next_header_filter = ngx_http_top_header_filter;
|
||||
ngx_http_top_header_filter = ngx_http_userid_filter;
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
|
||||
static void *
|
||||
ngx_http_userid_create_conf(ngx_conf_t *cf)
|
||||
{
|
||||
|
|
@ -693,6 +683,16 @@ ngx_http_userid_merge_conf(ngx_conf_t *cf, void *parent, void *child)
|
|||
}
|
||||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_userid_init(ngx_conf_t *cf)
|
||||
{
|
||||
ngx_http_next_header_filter = ngx_http_top_header_filter;
|
||||
ngx_http_top_header_filter = ngx_http_userid_filter;
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
ngx_http_userid_domain(ngx_conf_t *cf, void *post, void *data)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ WriteMakefile(
|
|||
ABSTRACT_FROM => 'nginx.pm', # retrieve abstract from module
|
||||
AUTHOR => 'Igor Sysoev',
|
||||
|
||||
CCFLAGS => "$ENV{NGX_PERL_CFLAGS}",
|
||||
CCFLAGS => "$ENV{NGX_PM_CFLAGS}",
|
||||
OPTIMIZE => '-O',
|
||||
|
||||
INC => "-I ../../../../../src/core " .
|
||||
|
|
@ -22,8 +22,9 @@ WriteMakefile(
|
|||
"-I ../../../../../src/http/modules " .
|
||||
"-I ../../../../../src/http/modules/perl " .
|
||||
"-I ../../../../../$ENV{NGX_OBJS} " .
|
||||
"-I ../../../../../$ENV{NGX_PCRE} " .
|
||||
"-I ../../../../../$ENV{NGX_ZLIB} ",
|
||||
($ENV{NGX_PCRE} =~ /^(YES|NO)/ ? "" :
|
||||
($ENV{NGX_PCRE} =~ m#^/# ? "-I $ENV{NGX_PCRE} " :
|
||||
"-I ../../../../../$ENV{NGX_PCRE} ")),
|
||||
|
||||
depend => {
|
||||
'nginx.c' =>
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ our @EXPORT = qw(
|
|||
HTTP_SERVER_ERROR
|
||||
);
|
||||
|
||||
our $VERSION = '0.3.43';
|
||||
our $VERSION = '0.4.0';
|
||||
|
||||
require XSLoader;
|
||||
XSLoader::load('nginx', $VERSION);
|
||||
|
|
|
|||
|
|
@ -328,6 +328,42 @@ header_in(r, key)
|
|||
ST(0) = TARG;
|
||||
|
||||
|
||||
void
|
||||
has_request_body(r, next)
|
||||
CODE:
|
||||
|
||||
dXSTARG;
|
||||
ngx_http_request_t *r;
|
||||
SV *next;
|
||||
ngx_http_perl_ctx_t *ctx;
|
||||
|
||||
ngx_http_perl_set_request(r);
|
||||
|
||||
if (r->headers_in.content_length_n <= 0) {
|
||||
XSRETURN_UNDEF;
|
||||
}
|
||||
|
||||
next = ST(1);
|
||||
|
||||
ctx = ngx_http_get_module_ctx(r, ngx_http_perl_module);
|
||||
ctx->next = next;
|
||||
|
||||
r->request_body_in_single_buf = 1;
|
||||
r->request_body_in_persistent_file = 1;
|
||||
r->request_body_delete_incomplete_file = 1;
|
||||
|
||||
if (r->request_body_in_file_only) {
|
||||
r->request_body_file_log_level = 0;
|
||||
}
|
||||
|
||||
ngx_http_read_client_request_body(r, ngx_http_perl_handle_request);
|
||||
|
||||
sv_upgrade(TARG, SVt_IV);
|
||||
sv_setiv(TARG, 1);
|
||||
|
||||
ST(0) = TARG;
|
||||
|
||||
|
||||
void
|
||||
request_body(r)
|
||||
CODE:
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@ static ngx_int_t ngx_http_perl_ssi(ngx_http_request_t *r,
|
|||
ngx_http_ssi_ctx_t *ssi_ctx, ngx_str_t **params);
|
||||
#endif
|
||||
|
||||
static void ngx_http_perl_handle_request(ngx_http_request_t *r);
|
||||
static ngx_int_t
|
||||
ngx_http_perl_get_interpreter(ngx_http_perl_main_conf_t *pmcf,
|
||||
PerlInterpreter **perl, ngx_log_t *log);
|
||||
|
|
@ -176,6 +175,9 @@ static ngx_http_ssi_command_t ngx_http_perl_ssi_command = {
|
|||
#endif
|
||||
|
||||
|
||||
static ngx_str_t ngx_null_name = ngx_null_string;
|
||||
|
||||
|
||||
static HV *nginx_stash;
|
||||
|
||||
static void
|
||||
|
|
@ -190,13 +192,16 @@ ngx_http_perl_xs_init(pTHX)
|
|||
static ngx_int_t
|
||||
ngx_http_perl_handler(ngx_http_request_t *r)
|
||||
{
|
||||
ngx_int_t rc;
|
||||
|
||||
/* TODO: Win32 */
|
||||
if (r->zero_in_uri) {
|
||||
return NGX_HTTP_NOT_FOUND;
|
||||
}
|
||||
|
||||
ngx_http_perl_handle_request(r);
|
||||
|
||||
return NGX_DONE;
|
||||
|
||||
#if 0
|
||||
r->request_body_in_single_buf = 1;
|
||||
r->request_body_in_persistent_file = 1;
|
||||
r->request_body_delete_incomplete_file = 1;
|
||||
|
|
@ -212,14 +217,16 @@ ngx_http_perl_handler(ngx_http_request_t *r)
|
|||
}
|
||||
|
||||
return NGX_DONE;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
void
|
||||
ngx_http_perl_handle_request(ngx_http_request_t *r)
|
||||
{
|
||||
SV *sub;
|
||||
ngx_int_t rc;
|
||||
ngx_str_t uri, args;
|
||||
ngx_str_t uri, args, *handler;
|
||||
ngx_http_perl_ctx_t *ctx;
|
||||
ngx_http_perl_loc_conf_t *plcf;
|
||||
ngx_http_perl_main_conf_t *pmcf;
|
||||
|
|
@ -231,7 +238,7 @@ ngx_http_perl_handle_request(ngx_http_request_t *r)
|
|||
if (ctx == NULL) {
|
||||
ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_perl_ctx_t));
|
||||
if (ctx == NULL) {
|
||||
ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
||||
ngx_http_finalize_request(r, NGX_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -251,10 +258,18 @@ ngx_http_perl_handle_request(ngx_http_request_t *r)
|
|||
|
||||
dTHXa(ctx->perl);
|
||||
|
||||
plcf = ngx_http_get_module_loc_conf(r, ngx_http_perl_module);
|
||||
if (ctx->next == NULL) {
|
||||
plcf = ngx_http_get_module_loc_conf(r, ngx_http_perl_module);
|
||||
sub = plcf->sub;
|
||||
handler = &plcf->handler;
|
||||
|
||||
rc = ngx_http_perl_call_handler(aTHX_ r, plcf->sub, NULL,
|
||||
&plcf->handler, NULL);
|
||||
} else {
|
||||
sub = ctx->next;
|
||||
handler = &ngx_null_name;
|
||||
ctx->next = NULL;
|
||||
}
|
||||
|
||||
rc = ngx_http_perl_call_handler(aTHX_ r, sub, NULL, handler, NULL);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -278,6 +293,10 @@ ngx_http_perl_handle_request(ngx_http_request_t *r)
|
|||
ctx->filename.data = NULL;
|
||||
ctx->redirect_uri.len = 0;
|
||||
|
||||
if (ctx->done || ctx->next) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (uri.len) {
|
||||
ngx_http_internal_redirect(r, &uri, &args);
|
||||
return;
|
||||
|
|
@ -285,6 +304,7 @@ ngx_http_perl_handle_request(ngx_http_request_t *r)
|
|||
|
||||
if (rc == NGX_OK || rc == NGX_HTTP_OK) {
|
||||
ngx_http_send_special(r, NGX_HTTP_LAST);
|
||||
ctx->done = 1;
|
||||
}
|
||||
|
||||
ngx_http_finalize_request(r, rc);
|
||||
|
|
@ -666,14 +686,6 @@ ngx_http_perl_run_requires(pTHX_ ngx_array_t *requires, ngx_log_t *log)
|
|||
}
|
||||
|
||||
|
||||
#if (__INTEL_COMPILER)
|
||||
/*
|
||||
* disable 'declaration hides parameter "my_perl"' warning for ENTER and LEAVE
|
||||
*/
|
||||
#pragma warning(disable:1599)
|
||||
#endif
|
||||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_perl_call_handler(pTHX_ ngx_http_request_t *r, SV *sub,
|
||||
ngx_str_t **args, ngx_str_t *handler, ngx_str_t *rv)
|
||||
|
|
@ -773,11 +785,6 @@ ngx_http_perl_call_handler(pTHX_ ngx_http_request_t *r, SV *sub,
|
|||
}
|
||||
|
||||
|
||||
#if (__INTEL_COMPILER)
|
||||
#pragma warning(default:1599)
|
||||
#endif
|
||||
|
||||
|
||||
static void
|
||||
ngx_http_perl_eval_anon_sub(pTHX_ ngx_str_t *handler, SV **sv)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -24,6 +24,9 @@ typedef struct {
|
|||
ngx_str_t filename;
|
||||
ngx_str_t redirect_uri;
|
||||
ngx_str_t redirect_args;
|
||||
SV *next;
|
||||
|
||||
ngx_uint_t done; /* unsigned done:1; */
|
||||
|
||||
#if (NGX_HTTP_SSI)
|
||||
ngx_http_ssi_ctx_t *ssi;
|
||||
|
|
@ -47,4 +50,7 @@ extern ngx_module_t ngx_http_perl_module;
|
|||
extern void boot_DynaLoader(pTHX_ CV* cv);
|
||||
|
||||
|
||||
void ngx_http_perl_handle_request(ngx_http_request_t *r);
|
||||
|
||||
|
||||
#endif /* _NGX_HTTP_PERL_MODULE_H_INCLUDED_ */
|
||||
|
|
|
|||
|
|
@ -75,8 +75,9 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||
{
|
||||
char *rv;
|
||||
u_char ch;
|
||||
ngx_int_t rc;
|
||||
ngx_uint_t mi, m, s, l, p, a, i;
|
||||
ngx_int_t rc, j;
|
||||
ngx_uint_t mi, m, s, l, p, a, i, n;
|
||||
ngx_uint_t find_config_index, use_rewrite, use_access;
|
||||
ngx_uint_t last, bind_all, done;
|
||||
ngx_conf_t pcf;
|
||||
ngx_array_t headers_in, in_ports;
|
||||
|
|
@ -93,9 +94,11 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||
ngx_http_conf_in_addr_t *in_addr;
|
||||
ngx_hash_keys_arrays_t ha;
|
||||
ngx_http_server_name_t *name;
|
||||
ngx_http_phase_handler_t *ph;
|
||||
ngx_http_virtual_names_t *vn;
|
||||
ngx_http_core_srv_conf_t **cscfp, *cscf;
|
||||
ngx_http_core_loc_conf_t *clcf;
|
||||
ngx_http_phase_handler_pt checker;
|
||||
ngx_http_core_main_conf_t *cmcf;
|
||||
#if (NGX_WIN32)
|
||||
ngx_iocp_conf_t *iocpcf;
|
||||
|
|
@ -293,8 +296,6 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
cmcf->phases[NGX_HTTP_POST_READ_PHASE].type = NGX_OK;
|
||||
|
||||
|
||||
if (ngx_array_init(&cmcf->phases[NGX_HTTP_SERVER_REWRITE_PHASE].handlers,
|
||||
cf->pool, 1, sizeof(ngx_http_handler_pt))
|
||||
|
|
@ -303,27 +304,6 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
cmcf->phases[NGX_HTTP_SERVER_REWRITE_PHASE].type = NGX_OK;
|
||||
|
||||
|
||||
/* the special find config phase for a single handler */
|
||||
|
||||
if (ngx_array_init(&cmcf->phases[NGX_HTTP_FIND_CONFIG_PHASE].handlers,
|
||||
cf->pool, 1, sizeof(ngx_http_handler_pt))
|
||||
!= NGX_OK)
|
||||
{
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
cmcf->phases[NGX_HTTP_FIND_CONFIG_PHASE].type = NGX_OK;
|
||||
|
||||
h = ngx_array_push(&cmcf->phases[NGX_HTTP_FIND_CONFIG_PHASE].handlers);
|
||||
if (h == NULL) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
*h = ngx_http_find_location_config;
|
||||
|
||||
|
||||
if (ngx_array_init(&cmcf->phases[NGX_HTTP_REWRITE_PHASE].handlers,
|
||||
cf->pool, 1, sizeof(ngx_http_handler_pt))
|
||||
|
|
@ -332,8 +312,6 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
cmcf->phases[NGX_HTTP_REWRITE_PHASE].type = NGX_OK;
|
||||
|
||||
|
||||
if (ngx_array_init(&cmcf->phases[NGX_HTTP_PREACCESS_PHASE].handlers,
|
||||
cf->pool, 1, sizeof(ngx_http_handler_pt))
|
||||
|
|
@ -342,8 +320,6 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
cmcf->phases[NGX_HTTP_PREACCESS_PHASE].type = NGX_OK;
|
||||
|
||||
|
||||
if (ngx_array_init(&cmcf->phases[NGX_HTTP_ACCESS_PHASE].handlers,
|
||||
cf->pool, 2, sizeof(ngx_http_handler_pt))
|
||||
|
|
@ -352,8 +328,6 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
cmcf->phases[NGX_HTTP_ACCESS_PHASE].type = NGX_DECLINED;
|
||||
|
||||
|
||||
if (ngx_array_init(&cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers,
|
||||
cf->pool, 4, sizeof(ngx_http_handler_pt))
|
||||
|
|
@ -362,8 +336,6 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
cmcf->phases[NGX_HTTP_CONTENT_PHASE].type = NGX_OK;
|
||||
|
||||
|
||||
if (ngx_array_init(&cmcf->phases[NGX_HTTP_LOG_PHASE].handlers,
|
||||
cf->pool, 1, sizeof(ngx_http_handler_pt))
|
||||
|
|
@ -372,8 +344,6 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
cmcf->phases[NGX_HTTP_LOG_PHASE].type = NGX_OK;
|
||||
|
||||
|
||||
if (ngx_array_init(&headers_in, cf->temp_pool, 32, sizeof(ngx_hash_key_t))
|
||||
!= NGX_OK)
|
||||
|
|
@ -432,6 +402,91 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||
*cf = pcf;
|
||||
|
||||
|
||||
cmcf->phase_engine.server_rewrite_index = (ngx_uint_t) -1;
|
||||
find_config_index = 0;
|
||||
use_rewrite = cmcf->phases[NGX_HTTP_REWRITE_PHASE].handlers.nelts ? 1 : 0;
|
||||
use_access = cmcf->phases[NGX_HTTP_ACCESS_PHASE].handlers.nelts ? 1 : 0;
|
||||
|
||||
n = use_rewrite + use_access + 1; /* find config phase */
|
||||
|
||||
for (i = 0; i < NGX_HTTP_LOG_PHASE; i++) {
|
||||
n += cmcf->phases[i].handlers.nelts;
|
||||
}
|
||||
|
||||
ph = ngx_pcalloc(cf->pool,
|
||||
n * sizeof(ngx_http_phase_handler_t) + sizeof(void *));
|
||||
if (ph == NULL) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
cmcf->phase_engine.handlers = ph;
|
||||
n = 0;
|
||||
|
||||
for (i = 0; i < NGX_HTTP_LOG_PHASE; i++) {
|
||||
h = cmcf->phases[i].handlers.elts;
|
||||
|
||||
switch (i) {
|
||||
|
||||
case NGX_HTTP_SERVER_REWRITE_PHASE:
|
||||
if (cmcf->phase_engine.server_rewrite_index == (ngx_uint_t) -1) {
|
||||
cmcf->phase_engine.server_rewrite_index = n;
|
||||
}
|
||||
checker = ngx_http_core_generic_phase;
|
||||
|
||||
break;
|
||||
|
||||
case NGX_HTTP_FIND_CONFIG_PHASE:
|
||||
find_config_index = n;
|
||||
|
||||
ph->checker = ngx_http_core_find_config_phase;
|
||||
n++;
|
||||
ph++;
|
||||
|
||||
continue;
|
||||
|
||||
case NGX_HTTP_POST_REWRITE_PHASE:
|
||||
if (use_rewrite) {
|
||||
ph->checker = ngx_http_core_post_rewrite_phase;
|
||||
ph->next = find_config_index;
|
||||
n++;
|
||||
ph++;
|
||||
}
|
||||
|
||||
continue;
|
||||
|
||||
case NGX_HTTP_ACCESS_PHASE:
|
||||
checker = ngx_http_core_access_phase;
|
||||
n++;
|
||||
break;
|
||||
|
||||
case NGX_HTTP_POST_ACCESS_PHASE:
|
||||
if (use_access) {
|
||||
ph->checker = ngx_http_core_post_access_phase;
|
||||
ph->next = n;
|
||||
ph++;
|
||||
}
|
||||
|
||||
continue;
|
||||
|
||||
case NGX_HTTP_CONTENT_PHASE:
|
||||
checker = ngx_http_core_content_phase;
|
||||
break;
|
||||
|
||||
default:
|
||||
checker = ngx_http_core_generic_phase;
|
||||
}
|
||||
|
||||
n += cmcf->phases[i].handlers.nelts;
|
||||
|
||||
for (j = cmcf->phases[i].handlers.nelts - 1; j >=0; j--) {
|
||||
ph->checker = checker;
|
||||
ph->handler = h[j];
|
||||
ph->next = n;
|
||||
ph++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* create the lists of ports, addresses and server names
|
||||
* to quickly find the server core module configuration at run-time
|
||||
|
|
@ -936,7 +991,6 @@ ngx_http_add_names(ngx_conf_t *cf, ngx_http_conf_in_addr_t *in_addr,
|
|||
if (name == NULL) {
|
||||
return NGX_ERROR;
|
||||
}
|
||||
server_names = cscf->server_names.elts;
|
||||
|
||||
*name = server_names[i];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ typedef struct {
|
|||
static void *ngx_http_copy_filter_create_conf(ngx_conf_t *cf);
|
||||
static char *ngx_http_copy_filter_merge_conf(ngx_conf_t *cf,
|
||||
void *parent, void *child);
|
||||
static ngx_int_t ngx_http_copy_filter_init(ngx_cycle_t *cycle);
|
||||
static ngx_int_t ngx_http_copy_filter_init(ngx_conf_t *cf);
|
||||
|
||||
|
||||
static ngx_command_t ngx_http_copy_filter_commands[] = {
|
||||
|
|
@ -35,7 +35,7 @@ static ngx_command_t ngx_http_copy_filter_commands[] = {
|
|||
|
||||
static ngx_http_module_t ngx_http_copy_filter_module_ctx = {
|
||||
NULL, /* preconfiguration */
|
||||
NULL, /* postconfiguration */
|
||||
ngx_http_copy_filter_init, /* postconfiguration */
|
||||
|
||||
NULL, /* create main configuration */
|
||||
NULL, /* init main configuration */
|
||||
|
|
@ -54,7 +54,7 @@ ngx_module_t ngx_http_copy_filter_module = {
|
|||
ngx_http_copy_filter_commands, /* module directives */
|
||||
NGX_HTTP_MODULE, /* module type */
|
||||
NULL, /* init master */
|
||||
ngx_http_copy_filter_init, /* init module */
|
||||
NULL, /* init module */
|
||||
NULL, /* init process */
|
||||
NULL, /* init thread */
|
||||
NULL, /* exit thread */
|
||||
|
|
@ -149,7 +149,7 @@ ngx_http_copy_filter_merge_conf(ngx_conf_t *cf, void *parent, void *child)
|
|||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_copy_filter_init(ngx_cycle_t *cycle)
|
||||
ngx_http_copy_filter_init(ngx_conf_t *cf)
|
||||
{
|
||||
ngx_http_next_filter = ngx_http_top_body_filter;
|
||||
ngx_http_top_body_filter = ngx_http_copy_filter;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ typedef struct {
|
|||
#define NGX_HTTP_LOCATION_REGEX 4
|
||||
|
||||
|
||||
static void ngx_http_core_run_phases(ngx_http_request_t *r);
|
||||
static ngx_int_t ngx_http_core_find_location(ngx_http_request_t *r,
|
||||
ngx_array_t *locations, size_t len);
|
||||
|
||||
|
|
@ -474,6 +473,8 @@ ngx_module_t ngx_http_core_module = {
|
|||
void
|
||||
ngx_http_handler(ngx_http_request_t *r)
|
||||
{
|
||||
ngx_http_core_main_conf_t *cmcf;
|
||||
|
||||
r->connection->log->action = NULL;
|
||||
|
||||
r->connection->unexpected_eof = 0;
|
||||
|
|
@ -500,8 +501,8 @@ ngx_http_handler(ngx_http_request_t *r)
|
|||
if (r->keepalive && r->headers_in.msie && r->method == NGX_HTTP_POST) {
|
||||
|
||||
/*
|
||||
* MSIE may wait for some time if the response for
|
||||
* the POST request is sent over the keepalive connection
|
||||
* MSIE may wait for some time if an response for
|
||||
* a POST request was sent over a keepalive connection
|
||||
*/
|
||||
|
||||
r->keepalive = 0;
|
||||
|
|
@ -515,172 +516,84 @@ ngx_http_handler(ngx_http_request_t *r)
|
|||
}
|
||||
}
|
||||
|
||||
r->write_event_handler = ngx_http_core_run_phases;
|
||||
|
||||
r->valid_unparsed_uri = 1;
|
||||
r->valid_location = 1;
|
||||
r->uri_changed = 1;
|
||||
|
||||
r->phase = (!r->internal) ? NGX_HTTP_POST_READ_PHASE:
|
||||
NGX_HTTP_SERVER_REWRITE_PHASE;
|
||||
r->phase_handler = 0;
|
||||
if (!r->internal) {
|
||||
r->phase_handler = 0;
|
||||
|
||||
} else {
|
||||
cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
|
||||
r->phase_handler = cmcf->phase_engine.server_rewrite_index;
|
||||
}
|
||||
|
||||
r->write_event_handler = ngx_http_core_run_phases;
|
||||
ngx_http_core_run_phases(r);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
void
|
||||
ngx_http_core_run_phases(ngx_http_request_t *r)
|
||||
{
|
||||
ngx_int_t rc;
|
||||
ngx_str_t path;
|
||||
ngx_http_handler_pt *h;
|
||||
ngx_http_core_loc_conf_t *clcf;
|
||||
ngx_http_phase_handler_t *ph;
|
||||
ngx_http_core_main_conf_t *cmcf;
|
||||
|
||||
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||
"http phase handler");
|
||||
|
||||
cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
|
||||
|
||||
for (/* void */; r->phase < NGX_HTTP_LOG_PHASE; r->phase++) {
|
||||
ph = cmcf->phase_engine.handlers;
|
||||
|
||||
if (r->phase == NGX_HTTP_REWRITE_PHASE + 1 && r->uri_changed) {
|
||||
while (ph[r->phase_handler].checker) {
|
||||
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||
"uri changes: %d", r->uri_changes);
|
||||
rc = ph[r->phase_handler].checker(r, &ph[r->phase_handler]);
|
||||
|
||||
/*
|
||||
* gcc before 3.3 compiles the broken code for
|
||||
* if (r->uri_changes-- == 0)
|
||||
* if the r->uri_changes is defined as
|
||||
* unsigned uri_changes:4
|
||||
*/
|
||||
|
||||
r->uri_changes--;
|
||||
|
||||
if (r->uri_changes == 0) {
|
||||
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
||||
"rewrite or internal redirection cycle "
|
||||
"while processing \"%V\"", &r->uri);
|
||||
ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
r->phase = NGX_HTTP_FIND_CONFIG_PHASE;
|
||||
}
|
||||
|
||||
if (r->phase == NGX_HTTP_ACCESS_PHASE && r != r->main) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (r->phase == NGX_HTTP_CONTENT_PHASE && r->content_handler) {
|
||||
r->write_event_handler = ngx_http_request_empty_handler;
|
||||
ngx_http_finalize_request(r, r->content_handler(r));
|
||||
return;
|
||||
}
|
||||
|
||||
h = cmcf->phases[r->phase].handlers.elts;
|
||||
for (r->phase_handler = cmcf->phases[r->phase].handlers.nelts - 1;
|
||||
r->phase_handler >= 0;
|
||||
r->phase_handler--)
|
||||
{
|
||||
rc = h[r->phase_handler](r);
|
||||
|
||||
if (rc == NGX_DONE) {
|
||||
|
||||
/*
|
||||
* we should never use r here because
|
||||
* it may point to already freed data
|
||||
*/
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (rc == NGX_DECLINED) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (r->phase == NGX_HTTP_ACCESS_PHASE) {
|
||||
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
|
||||
|
||||
if (clcf->satisfy_any) {
|
||||
|
||||
if (rc == NGX_OK) {
|
||||
r->access_code = 0;
|
||||
|
||||
if (r->headers_out.www_authenticate) {
|
||||
r->headers_out.www_authenticate->hash = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (rc == NGX_HTTP_FORBIDDEN || rc == NGX_HTTP_UNAUTHORIZED)
|
||||
{
|
||||
r->access_code = rc;
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rc >= NGX_HTTP_SPECIAL_RESPONSE
|
||||
|| rc == NGX_HTTP_NO_CONTENT
|
||||
|| rc == NGX_ERROR)
|
||||
{
|
||||
ngx_http_finalize_request(r, rc);
|
||||
return;
|
||||
}
|
||||
|
||||
if (r->phase == NGX_HTTP_CONTENT_PHASE) {
|
||||
ngx_http_finalize_request(r, rc);
|
||||
return;
|
||||
}
|
||||
|
||||
if (rc == NGX_AGAIN) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (rc == NGX_OK && cmcf->phases[r->phase].type == NGX_OK) {
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (r->phase == NGX_HTTP_ACCESS_PHASE && r->access_code) {
|
||||
|
||||
if (r->access_code == NGX_HTTP_FORBIDDEN) {
|
||||
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
||||
"access forbidden by rule");
|
||||
}
|
||||
|
||||
ngx_http_finalize_request(r, r->access_code);
|
||||
if (rc == NGX_OK) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* no content handler was found */
|
||||
|
||||
if (r->uri.data[r->uri.len - 1] == '/' && !r->zero_in_uri) {
|
||||
|
||||
if (ngx_http_map_uri_to_path(r, &path, 0) != NULL) {
|
||||
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
||||
"directory index of \"%V\" is forbidden", &path);
|
||||
}
|
||||
|
||||
ngx_http_finalize_request(r, NGX_HTTP_FORBIDDEN);
|
||||
return;
|
||||
}
|
||||
|
||||
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "no handler found");
|
||||
|
||||
ngx_http_finalize_request(r, NGX_HTTP_NOT_FOUND);
|
||||
}
|
||||
|
||||
|
||||
ngx_int_t
|
||||
ngx_http_find_location_config(ngx_http_request_t *r)
|
||||
ngx_http_core_generic_phase(ngx_http_request_t *r, ngx_http_phase_handler_t *ph)
|
||||
{
|
||||
ngx_int_t rc;
|
||||
|
||||
/*
|
||||
* generic phase checker,
|
||||
* used by the post read, server rewrite, rewrite, and pre-access phases
|
||||
*/
|
||||
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||
"generic phase: %ui", r->phase_handler);
|
||||
|
||||
rc = ph->handler(r);
|
||||
|
||||
if (rc == NGX_OK) {
|
||||
r->phase_handler = ph->next;
|
||||
return NGX_AGAIN;
|
||||
}
|
||||
|
||||
if (rc == NGX_DECLINED) {
|
||||
r->phase_handler++;
|
||||
return NGX_AGAIN;
|
||||
}
|
||||
|
||||
if (rc == NGX_AGAIN || rc == NGX_DONE) {
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
/* rc == NGX_ERROR || rc == NGX_HTTP_... */
|
||||
|
||||
ngx_http_finalize_request(r, rc);
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
|
||||
ngx_int_t
|
||||
ngx_http_core_find_config_phase(ngx_http_request_t *r,
|
||||
ngx_http_phase_handler_t *ph)
|
||||
{
|
||||
ngx_int_t rc;
|
||||
ngx_http_core_loc_conf_t *clcf;
|
||||
|
|
@ -694,13 +607,15 @@ ngx_http_find_location_config(ngx_http_request_t *r)
|
|||
rc = ngx_http_core_find_location(r, &cscf->locations, 0);
|
||||
|
||||
if (rc == NGX_HTTP_INTERNAL_SERVER_ERROR) {
|
||||
return rc;
|
||||
ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
|
||||
|
||||
if (!r->internal && clcf->internal) {
|
||||
return NGX_HTTP_NOT_FOUND;
|
||||
ngx_http_finalize_request(r, NGX_HTTP_NOT_FOUND);
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||
|
|
@ -723,14 +638,16 @@ ngx_http_find_location_config(ngx_http_request_t *r)
|
|||
"client intented to send too large body: %O bytes",
|
||||
r->headers_in.content_length_n);
|
||||
|
||||
return NGX_HTTP_REQUEST_ENTITY_TOO_LARGE;
|
||||
ngx_http_finalize_request(r, NGX_HTTP_REQUEST_ENTITY_TOO_LARGE);
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
|
||||
if (rc == NGX_HTTP_LOCATION_AUTO_REDIRECT) {
|
||||
r->headers_out.location = ngx_list_push(&r->headers_out.headers);
|
||||
if (r->headers_out.location == NULL) {
|
||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||
ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -740,9 +657,190 @@ ngx_http_find_location_config(ngx_http_request_t *r)
|
|||
|
||||
r->headers_out.location->value = clcf->name;
|
||||
|
||||
return NGX_HTTP_MOVED_PERMANENTLY;
|
||||
ngx_http_finalize_request(r, NGX_HTTP_MOVED_PERMANENTLY);
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
r->phase_handler++;
|
||||
return NGX_AGAIN;
|
||||
}
|
||||
|
||||
|
||||
ngx_int_t
|
||||
ngx_http_core_post_rewrite_phase(ngx_http_request_t *r,
|
||||
ngx_http_phase_handler_t *ph)
|
||||
{
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||
"post rewrite phase: %ui", r->phase_handler);
|
||||
|
||||
if (!r->uri_changed) {
|
||||
r->phase_handler++;
|
||||
return NGX_AGAIN;
|
||||
}
|
||||
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||
"uri changes: %d", r->uri_changes);
|
||||
|
||||
/*
|
||||
* gcc before 3.3 compiles the broken code for
|
||||
* if (r->uri_changes-- == 0)
|
||||
* if the r->uri_changes is defined as
|
||||
* unsigned uri_changes:4
|
||||
*/
|
||||
|
||||
r->uri_changes--;
|
||||
|
||||
if (r->uri_changes == 0) {
|
||||
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
||||
"rewrite or internal redirection cycle "
|
||||
"while processing \"%V\"", &r->uri);
|
||||
|
||||
ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
r->phase_handler = ph->next;
|
||||
|
||||
return NGX_AGAIN;
|
||||
}
|
||||
|
||||
|
||||
ngx_int_t
|
||||
ngx_http_core_access_phase(ngx_http_request_t *r, ngx_http_phase_handler_t *ph)
|
||||
{
|
||||
ngx_int_t rc;
|
||||
ngx_http_core_loc_conf_t *clcf;
|
||||
|
||||
if (r != r->main) {
|
||||
r->phase_handler = ph->next;
|
||||
return NGX_AGAIN;
|
||||
}
|
||||
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||
"access phase: %ui", r->phase_handler);
|
||||
|
||||
rc = ph->handler(r);
|
||||
|
||||
if (rc == NGX_DECLINED) {
|
||||
r->phase_handler++;
|
||||
return NGX_AGAIN;
|
||||
}
|
||||
|
||||
if (rc == NGX_AGAIN || rc == NGX_DONE) {
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
|
||||
|
||||
if (clcf->satisfy_any == 0) {
|
||||
|
||||
if (rc == NGX_OK) {
|
||||
r->phase_handler++;
|
||||
return NGX_AGAIN;
|
||||
}
|
||||
|
||||
} else {
|
||||
if (rc == NGX_OK) {
|
||||
r->access_code = 0;
|
||||
|
||||
if (r->headers_out.www_authenticate) {
|
||||
r->headers_out.www_authenticate->hash = 0;
|
||||
}
|
||||
|
||||
r->phase_handler = ph->next;
|
||||
return NGX_AGAIN;
|
||||
}
|
||||
|
||||
if (rc == NGX_HTTP_FORBIDDEN || rc == NGX_HTTP_UNAUTHORIZED) {
|
||||
r->access_code = rc;
|
||||
|
||||
r->phase_handler++;
|
||||
return NGX_AGAIN;
|
||||
}
|
||||
}
|
||||
|
||||
/* rc == NGX_ERROR || rc == NGX_HTTP_... */
|
||||
|
||||
ngx_http_finalize_request(r, rc);
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
|
||||
ngx_int_t
|
||||
ngx_http_core_post_access_phase(ngx_http_request_t *r,
|
||||
ngx_http_phase_handler_t *ph)
|
||||
{
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||
"post access phase: %ui", r->phase_handler);
|
||||
|
||||
if (r->access_code) {
|
||||
|
||||
if (r->access_code == NGX_HTTP_FORBIDDEN) {
|
||||
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
||||
"access forbidden by rule");
|
||||
}
|
||||
|
||||
ngx_http_finalize_request(r, r->access_code);
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
r->phase_handler++;
|
||||
return NGX_AGAIN;
|
||||
}
|
||||
|
||||
|
||||
ngx_int_t
|
||||
ngx_http_core_content_phase(ngx_http_request_t *r,
|
||||
ngx_http_phase_handler_t *ph)
|
||||
{
|
||||
ngx_int_t rc;
|
||||
ngx_str_t path;
|
||||
|
||||
if (r->content_handler) {
|
||||
r->write_event_handler = ngx_http_request_empty_handler;
|
||||
ngx_http_finalize_request(r, r->content_handler(r));
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||
"content phase: %ui", r->phase_handler);
|
||||
|
||||
rc = ph->handler(r);
|
||||
|
||||
if (rc == NGX_DONE) {
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
if (rc != NGX_DECLINED) {
|
||||
ngx_http_finalize_request(r, rc);
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
/* rc == NGX_DECLINED */
|
||||
|
||||
ph++;
|
||||
|
||||
if (ph->checker) {
|
||||
r->phase_handler++;
|
||||
return NGX_AGAIN;
|
||||
}
|
||||
|
||||
/* no content handler was found */
|
||||
|
||||
if (r->uri.data[r->uri.len - 1] == '/' && !r->zero_in_uri) {
|
||||
|
||||
if (ngx_http_map_uri_to_path(r, &path, 0) != NULL) {
|
||||
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
||||
"directory index of \"%V\" is forbidden", &path);
|
||||
}
|
||||
|
||||
ngx_http_finalize_request(r, NGX_HTTP_FORBIDDEN);
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "no handler found");
|
||||
|
||||
ngx_http_finalize_request(r, NGX_HTTP_NOT_FOUND);
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
|
|
@ -1916,7 +2014,7 @@ ngx_http_core_create_srv_conf(ngx_conf_t *cf)
|
|||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
if (ngx_array_init(&cscf->server_names, cf->pool, 4,
|
||||
if (ngx_array_init(&cscf->server_names, cf->temp_pool, 4,
|
||||
sizeof(ngx_http_server_name_t))
|
||||
== NGX_ERROR)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -49,28 +49,48 @@ typedef enum {
|
|||
NGX_HTTP_POST_READ_PHASE = 0,
|
||||
|
||||
NGX_HTTP_SERVER_REWRITE_PHASE,
|
||||
|
||||
NGX_HTTP_FIND_CONFIG_PHASE,
|
||||
NGX_HTTP_REWRITE_PHASE,
|
||||
NGX_HTTP_POST_REWRITE_PHASE,
|
||||
|
||||
NGX_HTTP_PREACCESS_PHASE,
|
||||
|
||||
NGX_HTTP_ACCESS_PHASE,
|
||||
NGX_HTTP_POST_ACCESS_PHASE,
|
||||
|
||||
NGX_HTTP_CONTENT_PHASE,
|
||||
|
||||
NGX_HTTP_LOG_PHASE
|
||||
} ngx_http_phases;
|
||||
|
||||
typedef struct ngx_http_phase_handler_s ngx_http_phase_handler_t;
|
||||
|
||||
typedef ngx_int_t (*ngx_http_phase_handler_pt)(ngx_http_request_t *r,
|
||||
ngx_http_phase_handler_t *ph);
|
||||
|
||||
struct ngx_http_phase_handler_s {
|
||||
ngx_http_phase_handler_pt checker;
|
||||
ngx_http_handler_pt handler;
|
||||
ngx_uint_t next;
|
||||
};
|
||||
|
||||
|
||||
typedef struct {
|
||||
ngx_http_phase_handler_t *handlers;
|
||||
ngx_uint_t server_rewrite_index;
|
||||
} ngx_http_phase_engine_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
ngx_array_t handlers;
|
||||
ngx_int_t type; /* NGX_OK, NGX_DECLINED */
|
||||
} ngx_http_phase_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
ngx_array_t servers; /* ngx_http_core_srv_conf_t */
|
||||
|
||||
ngx_http_phase_t phases[NGX_HTTP_LOG_PHASE + 1];
|
||||
ngx_http_phase_engine_t phase_engine;
|
||||
|
||||
ngx_hash_t headers_in_hash;
|
||||
|
||||
|
|
@ -85,6 +105,8 @@ typedef struct {
|
|||
ngx_uint_t variables_hash_bucket_size;
|
||||
|
||||
ngx_hash_keys_arrays_t *variables_keys;
|
||||
|
||||
ngx_http_phase_t phases[NGX_HTTP_LOG_PHASE + 1];
|
||||
} ngx_http_core_main_conf_t;
|
||||
|
||||
|
||||
|
|
@ -262,7 +284,19 @@ struct ngx_http_core_loc_conf_s {
|
|||
};
|
||||
|
||||
|
||||
ngx_int_t ngx_http_find_location_config(ngx_http_request_t *r);
|
||||
void ngx_http_core_run_phases(ngx_http_request_t *r);
|
||||
ngx_int_t ngx_http_core_generic_phase(ngx_http_request_t *r,
|
||||
ngx_http_phase_handler_t *ph);
|
||||
ngx_int_t ngx_http_core_find_config_phase(ngx_http_request_t *r,
|
||||
ngx_http_phase_handler_t *ph);
|
||||
ngx_int_t ngx_http_core_post_rewrite_phase(ngx_http_request_t *r,
|
||||
ngx_http_phase_handler_t *ph);
|
||||
ngx_int_t ngx_http_core_access_phase(ngx_http_request_t *r,
|
||||
ngx_http_phase_handler_t *ph);
|
||||
ngx_int_t ngx_http_core_post_access_phase(ngx_http_request_t *r,
|
||||
ngx_http_phase_handler_t *ph);
|
||||
ngx_int_t ngx_http_core_content_phase(ngx_http_request_t *r,
|
||||
ngx_http_phase_handler_t *ph);
|
||||
|
||||
ngx_int_t ngx_http_set_content_type(ngx_http_request_t *r);
|
||||
ngx_int_t ngx_http_set_exten(ngx_http_request_t *r);
|
||||
|
|
|
|||
|
|
@ -10,13 +10,13 @@
|
|||
#include <nginx.h>
|
||||
|
||||
|
||||
static ngx_int_t ngx_http_header_filter_init(ngx_cycle_t *cycle);
|
||||
static ngx_int_t ngx_http_header_filter_init(ngx_conf_t *cf);
|
||||
static ngx_int_t ngx_http_header_filter(ngx_http_request_t *r);
|
||||
|
||||
|
||||
static ngx_http_module_t ngx_http_header_filter_module_ctx = {
|
||||
NULL, /* preconfiguration */
|
||||
NULL, /* postconfiguration */
|
||||
ngx_http_header_filter_init, /* postconfiguration */
|
||||
|
||||
NULL, /* create main configuration */
|
||||
NULL, /* init main configuration */
|
||||
|
|
@ -35,7 +35,7 @@ ngx_module_t ngx_http_header_filter_module = {
|
|||
NULL, /* module directives */
|
||||
NGX_HTTP_MODULE, /* module type */
|
||||
NULL, /* init master */
|
||||
ngx_http_header_filter_init, /* init module */
|
||||
NULL, /* init module */
|
||||
NULL, /* init process */
|
||||
NULL, /* init thread */
|
||||
NULL, /* exit thread */
|
||||
|
|
@ -152,8 +152,8 @@ ngx_http_header_filter(ngx_http_request_t *r)
|
|||
{
|
||||
u_char *p;
|
||||
size_t len;
|
||||
ngx_uint_t status, i;
|
||||
ngx_buf_t *b;
|
||||
ngx_uint_t status, i;
|
||||
ngx_chain_t out;
|
||||
ngx_list_part_t *part;
|
||||
ngx_table_elt_t *header;
|
||||
|
|
@ -533,7 +533,7 @@ ngx_http_header_filter(ngx_http_request_t *r)
|
|||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_header_filter_init(ngx_cycle_t *cycle)
|
||||
ngx_http_header_filter_init(ngx_conf_t *cf)
|
||||
{
|
||||
ngx_http_top_header_filter = ngx_http_header_filter;
|
||||
|
||||
|
|
|
|||
|
|
@ -11,12 +11,12 @@
|
|||
|
||||
static ngx_int_t
|
||||
ngx_http_postpone_filter_output_postponed_request(ngx_http_request_t *r);
|
||||
static ngx_int_t ngx_http_postpone_filter_init(ngx_cycle_t *cycle);
|
||||
static ngx_int_t ngx_http_postpone_filter_init(ngx_conf_t *cf);
|
||||
|
||||
|
||||
static ngx_http_module_t ngx_http_postpone_filter_module_ctx = {
|
||||
NULL, /* preconfiguration */
|
||||
NULL, /* postconfiguration */
|
||||
ngx_http_postpone_filter_init, /* postconfiguration */
|
||||
|
||||
NULL, /* create main configuration */
|
||||
NULL, /* init main configuration */
|
||||
|
|
@ -35,7 +35,7 @@ ngx_module_t ngx_http_postpone_filter_module = {
|
|||
NULL, /* module directives */
|
||||
NGX_HTTP_MODULE, /* module type */
|
||||
NULL, /* init master */
|
||||
ngx_http_postpone_filter_init, /* init module */
|
||||
NULL, /* init module */
|
||||
NULL, /* init process */
|
||||
NULL, /* init thread */
|
||||
NULL, /* exit thread */
|
||||
|
|
@ -219,7 +219,7 @@ ngx_http_postpone_filter_output_postponed_request(ngx_http_request_t *r)
|
|||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_postpone_filter_init(ngx_cycle_t *cycle)
|
||||
ngx_http_postpone_filter_init(ngx_conf_t *cf)
|
||||
{
|
||||
ngx_http_next_filter = ngx_http_top_body_filter;
|
||||
ngx_http_top_body_filter = ngx_http_postpone_filter;
|
||||
|
|
|
|||
|
|
@ -140,6 +140,9 @@ ngx_http_header_t ngx_http_headers_in[] = {
|
|||
|
||||
{ ngx_string("Destination"), offsetof(ngx_http_headers_in_t, destination),
|
||||
ngx_http_process_header_line },
|
||||
|
||||
{ ngx_string("Date"), offsetof(ngx_http_headers_in_t, date),
|
||||
ngx_http_process_header_line },
|
||||
#endif
|
||||
|
||||
{ ngx_string("Cookie"), 0, ngx_http_process_cookie },
|
||||
|
|
@ -933,9 +936,11 @@ ngx_http_read_request_header(ngx_http_request_t *r)
|
|||
{
|
||||
ssize_t n;
|
||||
ngx_event_t *rev;
|
||||
ngx_connection_t *c;
|
||||
ngx_http_core_srv_conf_t *cscf;
|
||||
|
||||
rev = r->connection->read;
|
||||
c = r->connection;
|
||||
rev = c->read;
|
||||
|
||||
n = r->header_in->last - r->header_in->pos;
|
||||
|
||||
|
|
@ -944,8 +949,8 @@ ngx_http_read_request_header(ngx_http_request_t *r)
|
|||
}
|
||||
|
||||
if (rev->ready) {
|
||||
n = r->connection->recv(r->connection, r->header_in->last,
|
||||
r->header_in->end - r->header_in->last);
|
||||
n = c->recv(c, r->header_in->last,
|
||||
r->header_in->end - r->header_in->last);
|
||||
} else {
|
||||
n = NGX_AGAIN;
|
||||
}
|
||||
|
|
@ -966,11 +971,14 @@ ngx_http_read_request_header(ngx_http_request_t *r)
|
|||
}
|
||||
|
||||
if (n == 0) {
|
||||
ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
|
||||
ngx_log_error(NGX_LOG_INFO, c->log, 0,
|
||||
"client closed prematurely connection");
|
||||
}
|
||||
|
||||
if (n == 0 || n == NGX_ERROR) {
|
||||
c->error = rev->error;
|
||||
c->log->action = "sending response to client";
|
||||
|
||||
ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
|
@ -1155,8 +1163,9 @@ ngx_http_process_unique_header_line(ngx_http_request_t *r, ngx_table_elt_t *h,
|
|||
}
|
||||
|
||||
ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
|
||||
"client sent duplicate header line: \"%V: %V\"",
|
||||
&h->key, &h->value);
|
||||
"client sent duplicate header line: \"%V: %V\", "
|
||||
"previous value: \"%V: %V\"",
|
||||
&h->key, &h->value, &(*ph)->key, &(*ph)->value);
|
||||
|
||||
ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
|
||||
|
||||
|
|
@ -1460,6 +1469,13 @@ ngx_http_finalize_request(ngx_http_request_t *r, ngx_int_t rc)
|
|||
"http finalize request: %d, \"%V?%V\"",
|
||||
rc, &r->uri, &r->args);
|
||||
|
||||
if (rc == NGX_DECLINED) {
|
||||
r->content_handler = NULL;
|
||||
r->write_event_handler = ngx_http_core_run_phases;
|
||||
ngx_http_core_run_phases(r);
|
||||
return;
|
||||
}
|
||||
|
||||
if (r != r->main
|
||||
&& rc != NGX_ERROR
|
||||
&& !r->connection->error
|
||||
|
|
|
|||
|
|
@ -184,6 +184,7 @@ typedef struct {
|
|||
#if (NGX_HTTP_DAV)
|
||||
ngx_table_elt_t *depth;
|
||||
ngx_table_elt_t *destination;
|
||||
ngx_table_elt_t *date;
|
||||
#endif
|
||||
|
||||
ngx_str_t user;
|
||||
|
|
@ -352,7 +353,6 @@ struct ngx_http_request_s {
|
|||
ngx_str_t server_name;
|
||||
ngx_http_virtual_names_t *virtual_names;
|
||||
|
||||
ngx_uint_t phase;
|
||||
ngx_int_t phase_handler;
|
||||
ngx_http_handler_pt content_handler;
|
||||
ngx_uint_t access_code;
|
||||
|
|
|
|||
|
|
@ -417,12 +417,12 @@ ngx_http_discard_body(ngx_http_request_t *r)
|
|||
ngx_del_timer(rev);
|
||||
}
|
||||
|
||||
r->discard_body = 1;
|
||||
|
||||
if (r->headers_in.content_length_n <= 0) {
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
r->discard_body = 1;
|
||||
|
||||
size = r->header_in->last - r->header_in->pos;
|
||||
|
||||
if (size) {
|
||||
|
|
|
|||
|
|
@ -307,7 +307,7 @@ ngx_http_special_response_handler(ngx_http_request_t *r, ngx_int_t error)
|
|||
ngx_int_t rc;
|
||||
ngx_buf_t *b;
|
||||
ngx_str_t *uri, *location;
|
||||
ngx_uint_t i, err, msie_padding;
|
||||
ngx_uint_t i, n, err, msie_padding;
|
||||
ngx_chain_t *out, *cl;
|
||||
ngx_http_err_page_t *err_page;
|
||||
ngx_http_core_loc_conf_t *clcf;
|
||||
|
|
@ -375,8 +375,23 @@ ngx_http_special_response_handler(ngx_http_request_t *r, ngx_int_t error)
|
|||
{
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
if (r->zero_in_uri) {
|
||||
for (n = 0; n < uri->len; n++) {
|
||||
if (uri->data[n] == '\0') {
|
||||
goto zero;
|
||||
}
|
||||
}
|
||||
|
||||
r->zero_in_uri = 0;
|
||||
}
|
||||
|
||||
} else {
|
||||
r->zero_in_uri = 0;
|
||||
}
|
||||
|
||||
zero:
|
||||
|
||||
if (uri->data[0] == '/') {
|
||||
return ngx_http_internal_redirect(r, uri, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1134,11 +1134,11 @@ ngx_http_upstream_process_header(ngx_event_t *rev)
|
|||
}
|
||||
}
|
||||
|
||||
umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module);
|
||||
|
||||
if (r->upstream->headers_in.x_accel_redirect) {
|
||||
ngx_http_upstream_finalize_request(r, u, NGX_DECLINED);
|
||||
|
||||
umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module);
|
||||
|
||||
part = &r->upstream->headers_in.headers.part;
|
||||
h = part->elts;
|
||||
|
||||
|
|
@ -1188,29 +1188,6 @@ ngx_http_upstream_process_header(ngx_event_t *rev)
|
|||
return;
|
||||
}
|
||||
|
||||
ngx_http_upstream_send_response(r, u);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
ngx_http_upstream_send_response(ngx_http_request_t *r, ngx_http_upstream_t *u)
|
||||
{
|
||||
int tcp_nodelay;
|
||||
ssize_t size;
|
||||
ngx_int_t rc;
|
||||
ngx_uint_t i;
|
||||
ngx_list_part_t *part;
|
||||
ngx_table_elt_t *h;
|
||||
ngx_event_pipe_t *p;
|
||||
ngx_connection_t *c;
|
||||
ngx_pool_cleanup_t *cl;
|
||||
ngx_pool_cleanup_file_t *clf;
|
||||
ngx_http_core_loc_conf_t *clcf;
|
||||
ngx_http_upstream_header_t *hh;
|
||||
ngx_http_upstream_main_conf_t *umcf;
|
||||
|
||||
umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module);
|
||||
|
||||
part = &r->upstream->headers_in.headers.part;
|
||||
h = part->elts;
|
||||
|
||||
|
|
@ -1270,6 +1247,22 @@ ngx_http_upstream_send_response(ngx_http_request_t *r, ngx_http_upstream_t *u)
|
|||
u->length = NGX_MAX_SIZE_T_VALUE;
|
||||
}
|
||||
|
||||
ngx_http_upstream_send_response(r, u);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
ngx_http_upstream_send_response(ngx_http_request_t *r, ngx_http_upstream_t *u)
|
||||
{
|
||||
int tcp_nodelay;
|
||||
ssize_t size;
|
||||
ngx_int_t rc;
|
||||
ngx_event_pipe_t *p;
|
||||
ngx_connection_t *c;
|
||||
ngx_pool_cleanup_t *cl;
|
||||
ngx_pool_cleanup_file_t *clf;
|
||||
ngx_http_core_loc_conf_t *clcf;
|
||||
|
||||
rc = ngx_http_send_header(r);
|
||||
|
||||
if (rc == NGX_ERROR || rc > NGX_OK || r->post_action) {
|
||||
|
|
|
|||
|
|
@ -10,12 +10,12 @@
|
|||
#include <ngx_http.h>
|
||||
|
||||
|
||||
static ngx_int_t ngx_http_write_filter_init(ngx_cycle_t *cycle);
|
||||
static ngx_int_t ngx_http_write_filter_init(ngx_conf_t *cf);
|
||||
|
||||
|
||||
static ngx_http_module_t ngx_http_write_filter_module_ctx = {
|
||||
NULL, /* preconfiguration */
|
||||
NULL, /* postconfiguration */
|
||||
ngx_http_write_filter_init, /* postconfiguration */
|
||||
|
||||
NULL, /* create main configuration */
|
||||
NULL, /* init main configuration */
|
||||
|
|
@ -34,7 +34,7 @@ ngx_module_t ngx_http_write_filter_module = {
|
|||
NULL, /* module directives */
|
||||
NGX_HTTP_MODULE, /* module type */
|
||||
NULL, /* init master */
|
||||
ngx_http_write_filter_init, /* init module */
|
||||
NULL, /* init module */
|
||||
NULL, /* init process */
|
||||
NULL, /* init thread */
|
||||
NULL, /* exit thread */
|
||||
|
|
@ -271,7 +271,7 @@ ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_write_filter_init(ngx_cycle_t *cycle)
|
||||
ngx_http_write_filter_init(ngx_conf_t *cf)
|
||||
{
|
||||
ngx_http_top_body_filter = ngx_http_write_filter;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue