diff options
Diffstat (limited to 'src/http')
-rw-r--r-- | src/http/modules/ngx_http_fastcgi_module.c | 2 | ||||
-rw-r--r-- | src/http/modules/ngx_http_proxy_module.c | 2 | ||||
-rw-r--r-- | src/http/modules/perl/nginx.xs | 6 | ||||
-rw-r--r-- | src/http/modules/perl/ngx_http_perl_module.c | 7 | ||||
-rw-r--r-- | src/http/ngx_http_core_module.c | 43 | ||||
-rw-r--r-- | src/http/ngx_http_core_module.h | 8 | ||||
-rw-r--r-- | src/http/ngx_http_request_body.c | 2 | ||||
-rw-r--r-- | src/http/ngx_http_script.c | 4 | ||||
-rw-r--r-- | src/http/ngx_http_special_response.c | 24 | ||||
-rw-r--r-- | src/http/ngx_http_upstream.c | 2 |
10 files changed, 70 insertions, 30 deletions
diff --git a/src/http/modules/ngx_http_fastcgi_module.c b/src/http/modules/ngx_http_fastcgi_module.c index 8d5ef95d2..98e098b49 100644 --- a/src/http/modules/ngx_http_fastcgi_module.c +++ b/src/http/modules/ngx_http_fastcgi_module.c @@ -2056,7 +2056,7 @@ ngx_http_fastcgi_lowat_check(ngx_conf_t *cf, void *post, void *data) #if (NGX_FREEBSD) ssize_t *np = data; - if (*np >= ngx_freebsd_net_inet_tcp_sendspace) { + if ((u_long) *np >= ngx_freebsd_net_inet_tcp_sendspace) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "\"fastcgi_send_lowat\" must be less than %d " "(sysctl net.inet.tcp.sendspace)", diff --git a/src/http/modules/ngx_http_proxy_module.c b/src/http/modules/ngx_http_proxy_module.c index a6adc3cbd..0d80b3143 100644 --- a/src/http/modules/ngx_http_proxy_module.c +++ b/src/http/modules/ngx_http_proxy_module.c @@ -2343,7 +2343,7 @@ ngx_http_proxy_lowat_check(ngx_conf_t *cf, void *post, void *data) #if (NGX_FREEBSD) ssize_t *np = data; - if (*np >= ngx_freebsd_net_inet_tcp_sendspace) { + if ((u_long) *np >= ngx_freebsd_net_inet_tcp_sendspace) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "\"proxy_send_lowat\" must be less than %d " "(sysctl net.inet.tcp.sendspace)", diff --git a/src/http/modules/perl/nginx.xs b/src/http/modules/perl/nginx.xs index 8e287a6b2..53b6a9230 100644 --- a/src/http/modules/perl/nginx.xs +++ b/src/http/modules/perl/nginx.xs @@ -116,10 +116,8 @@ send_http_header(r, ...) } } else { - if (r->headers_out.content_type.len == 0) { - if (ngx_http_set_content_type(r) != NGX_OK) { - XSRETURN_EMPTY; - } + if (ngx_http_set_content_type(r) != NGX_OK) { + XSRETURN_EMPTY; } } diff --git a/src/http/modules/perl/ngx_http_perl_module.c b/src/http/modules/perl/ngx_http_perl_module.c index b3e117584..6f979c661 100644 --- a/src/http/modules/perl/ngx_http_perl_module.c +++ b/src/http/modules/perl/ngx_http_perl_module.c @@ -226,13 +226,6 @@ ngx_http_perl_handle_request(ngx_http_request_t *r) ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "perl handler"); - /* mod_perl's content handler assumes that content type was already set */ - - if (ngx_http_set_content_type(r) != NGX_OK) { - ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); - return; - } - ctx = ngx_http_get_module_ctx(r, ngx_http_perl_module); if (ctx == NULL) { diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c index 9d33d3af6..764f35c57 100644 --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -700,6 +700,7 @@ ngx_http_find_location_config(ngx_http_request_t *r) r->headers_in.content_length_n, clcf->client_max_body_size); if (r->headers_in.content_length_n != -1 + && !r->discard_body && clcf->client_max_body_size && clcf->client_max_body_size < r->headers_in.content_length_n) { @@ -929,6 +930,10 @@ ngx_http_set_content_type(ngx_http_request_t *r) ngx_uint_t i, hash; ngx_http_core_loc_conf_t *clcf; + if (r->headers_out.content_type.len) { + return NGX_OK; + } + clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); if (r->exten.len) { @@ -2688,10 +2693,12 @@ ngx_http_core_error_page(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { ngx_http_core_loc_conf_t *lcf = conf; - ngx_int_t overwrite; - ngx_uint_t i, n; - ngx_str_t *value; - ngx_http_err_page_t *err; + ngx_int_t overwrite; + ngx_str_t *value, uri; + ngx_uint_t i, n, nvar; + ngx_array_t *uri_lengths, *uri_values; + ngx_http_err_page_t *err; + ngx_http_script_compile_t sc; if (lcf->error_pages == NULL) { lcf->error_pages = ngx_array_create(cf->pool, 4, @@ -2732,6 +2739,28 @@ ngx_http_core_error_page(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) n = 1; } + uri = value[cf->args->nelts - 1]; + uri_lengths = NULL; + uri_values = NULL; + + nvar = ngx_http_script_variables_count(&uri); + + if (nvar) { + ngx_memzero(&sc, sizeof(ngx_http_script_compile_t)); + + sc.cf = cf; + sc.source = &uri; + sc.lengths = &uri_lengths; + sc.values = &uri_values; + sc.variables = nvar; + sc.complete_lengths = 1; + sc.complete_values = 1; + + if (ngx_http_script_compile(&sc) != NGX_OK) { + return NGX_CONF_ERROR; + } + } + for (i = 1; i < cf->args->nelts - n; i++) { err = ngx_array_push(lcf->error_pages); if (err == NULL) { @@ -2755,7 +2784,9 @@ ngx_http_core_error_page(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) err->overwrite = (overwrite >= 0) ? overwrite : err->status; - err->uri = value[cf->args->nelts - 1]; + err->uri = uri; + err->uri_lengths = uri_lengths; + err->uri_values = uri_values; } return NGX_CONF_OK; @@ -2838,7 +2869,7 @@ ngx_http_core_lowat_check(ngx_conf_t *cf, void *post, void *data) #if (NGX_FREEBSD) ssize_t *np = data; - if (*np >= ngx_freebsd_net_inet_tcp_sendspace) { + if ((u_long) *np >= ngx_freebsd_net_inet_tcp_sendspace) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "\"send_lowat\" must be less than %d " "(sysctl net.inet.tcp.sendspace)", diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h index 5ea81032f..35f865827 100644 --- a/src/http/ngx_http_core_module.h +++ b/src/http/ngx_http_core_module.h @@ -171,9 +171,11 @@ typedef struct { typedef struct { - ngx_int_t status; - ngx_int_t overwrite; - ngx_str_t uri; + ngx_int_t status; + ngx_int_t overwrite; + ngx_str_t uri; + ngx_array_t *uri_lengths; + ngx_array_t *uri_values; } ngx_http_err_page_t; diff --git a/src/http/ngx_http_request_body.c b/src/http/ngx_http_request_body.c index 460cf399d..fb183c68e 100644 --- a/src/http/ngx_http_request_body.c +++ b/src/http/ngx_http_request_body.c @@ -405,7 +405,7 @@ ngx_http_discard_body(ngx_http_request_t *r) ssize_t size; ngx_event_t *rev; - if (r != r->main) { + if (r != r->main || r->discard_body) { return NGX_OK; } diff --git a/src/http/ngx_http_script.c b/src/http/ngx_http_script.c index 1918397fb..2169c87ed 100644 --- a/src/http/ngx_http_script.c +++ b/src/http/ngx_http_script.c @@ -792,6 +792,10 @@ ngx_http_script_regex_end_code(ngx_http_script_engine_t *e) } else { e->buf.len = e->pos - e->buf.data; + + if (!code->add_args) { + r->args.len = 0; + } } if (e->log) { diff --git a/src/http/ngx_http_special_response.c b/src/http/ngx_http_special_response.c index 734ad6947..dfff64107 100644 --- a/src/http/ngx_http_special_response.c +++ b/src/http/ngx_http_special_response.c @@ -295,8 +295,9 @@ ngx_int_t ngx_http_special_response_handler(ngx_http_request_t *r, ngx_int_t error) { ngx_int_t rc; - ngx_uint_t i, err, msie_padding; ngx_buf_t *b; + ngx_str_t *uri; + ngx_uint_t i, err, msie_padding; ngx_chain_t *out, *cl; ngx_http_err_page_t *err_page; ngx_http_core_loc_conf_t *clcf; @@ -349,9 +350,20 @@ ngx_http_special_response_handler(ngx_http_request_t *r, ngx_int_t error) r->method = NGX_HTTP_GET; - if (err_page[i].uri.data[0] == '/') { - return ngx_http_internal_redirect(r, &err_page[i].uri, - NULL); + uri = &err_page[i].uri; + + if (err_page[i].uri_lengths) { + if (ngx_http_script_run(r, uri, + err_page[i].uri_lengths->elts, 0, + err_page[i].uri_values->elts) + == NULL) + { + return NGX_ERROR; + } + } + + if (uri->data[0] == '/') { + return ngx_http_internal_redirect(r, uri, NULL); } r->headers_out.location = @@ -364,10 +376,10 @@ ngx_http_special_response_handler(ngx_http_request_t *r, ngx_int_t error) r->headers_out.location->hash = 1; r->headers_out.location->key.len = sizeof("Location") - 1; r->headers_out.location->key.data = (u_char *) "Location"; - r->headers_out.location->value = err_page[i].uri; + r->headers_out.location->value = *uri; } else { - error = NGX_HTTP_INTERNAL_SERVER_ERROR; + return NGX_ERROR; } } } diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c index 5e22f2d83..d5b7aee53 100644 --- a/src/http/ngx_http_upstream.c +++ b/src/http/ngx_http_upstream.c @@ -110,7 +110,7 @@ ngx_http_upstream_header_t ngx_http_upstream_headers_in[] = { { ngx_string("Content-Type"), ngx_http_upstream_process_header_line, offsetof(ngx_http_upstream_headers_in_t, content_type), - ngx_http_upstream_copy_content_type, 0, 0 }, + ngx_http_upstream_copy_content_type, 0, 1 }, { ngx_string("Content-Length"), ngx_http_upstream_process_header_line, |