summaryrefslogtreecommitdiffhomepage
path: root/src/http
diff options
context:
space:
mode:
Diffstat (limited to 'src/http')
-rw-r--r--src/http/modules/ngx_http_access_module.c9
-rw-r--r--src/http/modules/ngx_http_auth_basic_module.c2
-rw-r--r--src/http/modules/ngx_http_charset_filter_module.c45
-rw-r--r--src/http/modules/ngx_http_dav_module.c21
-rw-r--r--src/http/modules/ngx_http_fastcgi_module.c18
-rw-r--r--src/http/modules/ngx_http_gzip_filter_module.c2
-rw-r--r--src/http/modules/ngx_http_headers_filter_module.c9
-rw-r--r--src/http/modules/ngx_http_log_module.c2
-rw-r--r--src/http/modules/ngx_http_memcached_module.c2
-rw-r--r--src/http/modules/ngx_http_proxy_module.c17
-rw-r--r--src/http/modules/ngx_http_realip_module.c2
-rw-r--r--src/http/modules/ngx_http_rewrite_module.c2
-rw-r--r--src/http/modules/ngx_http_userid_filter_module.c4
-rw-r--r--src/http/modules/perl/ngx_http_perl_module.c4
-rw-r--r--src/http/ngx_http_core_module.c33
-rw-r--r--src/http/ngx_http_core_module.h5
-rw-r--r--src/http/ngx_http_header_filter_module.c2
-rw-r--r--src/http/ngx_http_request.c9
-rw-r--r--src/http/ngx_http_request.h6
-rw-r--r--src/http/ngx_http_request_body.c25
-rw-r--r--src/http/ngx_http_upstream.c41
-rw-r--r--src/http/ngx_http_upstream.h2
22 files changed, 169 insertions, 93 deletions
diff --git a/src/http/modules/ngx_http_access_module.c b/src/http/modules/ngx_http_access_module.c
index 710dd248e..b8aa3aae2 100644
--- a/src/http/modules/ngx_http_access_module.c
+++ b/src/http/modules/ngx_http_access_module.c
@@ -92,6 +92,7 @@ ngx_http_access_handler(ngx_http_request_t *r)
ngx_uint_t i;
struct sockaddr_in *sin;
ngx_http_access_rule_t *rule;
+ ngx_http_core_loc_conf_t *clcf;
ngx_http_access_loc_conf_t *alcf;
alcf = ngx_http_get_module_loc_conf(r, ngx_http_access_module);
@@ -113,8 +114,12 @@ ngx_http_access_handler(ngx_http_request_t *r)
if ((sin->sin_addr.s_addr & rule[i].mask) == rule[i].addr) {
if (rule[i].deny) {
- ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
- "access forbidden by rule");
+ clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
+
+ if (!clcf->satisfy_any) {
+ ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
+ "access forbidden by rule");
+ }
return NGX_HTTP_FORBIDDEN;
}
diff --git a/src/http/modules/ngx_http_auth_basic_module.c b/src/http/modules/ngx_http_auth_basic_module.c
index d33e7f6cf..5dd287609 100644
--- a/src/http/modules/ngx_http_auth_basic_module.c
+++ b/src/http/modules/ngx_http_auth_basic_module.c
@@ -136,7 +136,7 @@ ngx_http_auth_basic_handler(ngx_http_request_t *r)
fd = ngx_open_file(alcf->user_file.data, NGX_FILE_RDONLY, NGX_FILE_OPEN);
if (fd == NGX_INVALID_FILE) {
- ngx_log_error(NGX_LOG_ERR, r->connection->log, ngx_errno,
+ ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno,
ngx_open_file_n " \"%s\" failed", alcf->user_file.data);
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
diff --git a/src/http/modules/ngx_http_charset_filter_module.c b/src/http/modules/ngx_http_charset_filter_module.c
index 41a0e5751..0bc31bca5 100644
--- a/src/http/modules/ngx_http_charset_filter_module.c
+++ b/src/http/modules/ngx_http_charset_filter_module.c
@@ -188,7 +188,7 @@ ngx_http_charset_header_filter(ngx_http_request_t *r)
{
u_char *ct;
ngx_int_t charset, source_charset;
- ngx_str_t *mc;
+ ngx_str_t *mc, *from, *to;
ngx_uint_t n;
ngx_http_charset_t *charsets;
ngx_http_charset_ctx_t *ctx;
@@ -288,13 +288,10 @@ ngx_http_charset_header_filter(ngx_http_request_t *r)
return ngx_http_next_header_filter(r);
}
- ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
- "no \"charset_map\" between the charsets "
- "\"%V\" and \"%V\"",
- &charsets[lcf->source_charset].name,
- &r->main->headers_out.charset);
+ from = &charsets[lcf->source_charset].name;
+ to = &r->main->headers_out.charset;
- return ngx_http_next_header_filter(r);
+ goto no_charset_map;
}
source_charset = ngx_http_charset_get_charset(charsets, n,
@@ -308,11 +305,12 @@ ngx_http_charset_header_filter(ngx_http_request_t *r)
r->headers_out.charset.data)
!= 0)
{
- ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
- "no \"charset_map\" between the charsets "
- "\"%V\" and \"%V\"",
- &r->headers_out.charset,
- &r->main->headers_out.charset);
+ from = &r->headers_out.charset;
+ to = (charset == NGX_HTTP_NO_CHARSET) ?
+ &r->main->headers_out.charset:
+ &charsets[charset].name;
+
+ goto no_charset_map;
}
return ngx_http_next_header_filter(r);
@@ -322,18 +320,24 @@ ngx_http_charset_header_filter(ngx_http_request_t *r)
&& (charsets[source_charset].tables == NULL
|| charsets[source_charset].tables[charset] == NULL))
{
- ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
- "no \"charset_map\" between the charsets "
- "\"%V\" and \"%V\"",
- &charsets[source_charset].name, &charsets[charset].name);
+ from = &charsets[source_charset].name;
+ to = &charsets[charset].name;
- return ngx_http_next_header_filter(r);
+ goto no_charset_map;
}
r->headers_out.content_type.len = r->headers_out.content_type_len;
return ngx_http_charset_set_charset(r, mcf->charsets.elts, charset,
source_charset);
+
+no_charset_map:
+
+ ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
+ "no \"charset_map\" between the charsets "
+ "\"%V\" and \"%V\"", from, to);
+
+ return ngx_http_next_header_filter(r);
}
@@ -392,11 +396,14 @@ ngx_http_charset_set_charset(ngx_http_request_t *r,
ctx->from_utf8 = charsets[source_charset].utf8;
ctx->to_utf8 = charsets[charset].utf8;
+ r->filter_need_in_memory = 1;
+
if ((ctx->to_utf8 || ctx->from_utf8) && r == r->main) {
ngx_http_clear_content_length(r);
- }
- r->filter_need_in_memory = 1;
+ } else {
+ r->filter_need_temporary = 1;
+ }
return ngx_http_next_header_filter(r);
}
diff --git a/src/http/modules/ngx_http_dav_module.c b/src/http/modules/ngx_http_dav_module.c
index 7f61774e7..53ef21c45 100644
--- a/src/http/modules/ngx_http_dav_module.c
+++ b/src/http/modules/ngx_http_dav_module.c
@@ -251,17 +251,20 @@ ngx_http_dav_put_handler(ngx_http_request_t *r)
} else {
status = NGX_HTTP_NO_CONTENT;
- }
- if (ngx_is_dir(&fi)) {
- 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",
- temp->data);
- }
+ if (ngx_is_dir(&fi)) {
+ ngx_log_error(NGX_LOG_ERR, r->connection->log, NGX_EISDIR,
+ "\"%s\" could not be created", path.data);
+
+ 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",
+ temp->data);
+ }
- ngx_http_finalize_request(r, NGX_HTTP_CONFLICT);
- return;
+ ngx_http_finalize_request(r, NGX_HTTP_CONFLICT);
+ return;
+ }
}
if (ngx_rename_file(temp->data, path.data) != NGX_FILE_ERROR) {
diff --git a/src/http/modules/ngx_http_fastcgi_module.c b/src/http/modules/ngx_http_fastcgi_module.c
index 085fb47e4..172a1a74d 100644
--- a/src/http/modules/ngx_http_fastcgi_module.c
+++ b/src/http/modules/ngx_http_fastcgi_module.c
@@ -1565,6 +1565,7 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
uintptr_t *code;
ngx_str_t *header;
ngx_uint_t i, j;
+ ngx_peer_t *peer;
ngx_array_t hide_headers;
ngx_keyval_t *src;
ngx_hash_key_t *hk;
@@ -1693,20 +1694,23 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|NGX_HTTP_UPSTREAM_FT_ERROR
|NGX_HTTP_UPSTREAM_FT_TIMEOUT));
- ngx_conf_merge_unsigned_value(conf->upstream.max_fails,
+ ngx_conf_merge_uint_value(conf->upstream.max_fails,
prev->upstream.max_fails, 1);
ngx_conf_merge_sec_value(conf->upstream.fail_timeout,
prev->upstream.fail_timeout, 10);
- if (conf->upstream_peers && !conf->upstream_peers->balanced) {
+ if (conf->upstream_peers) {
+ peer = conf->upstream_peers->peers->peer;
for (i = 0; i < conf->upstream_peers->peers->number; i++) {
- conf->upstream_peers->peers->peer[i].weight = 1;
- conf->upstream_peers->peers->peer[i].max_fails =
- conf->upstream.max_fails;
- conf->upstream_peers->peers->peer[i].fail_timeout =
- conf->upstream.fail_timeout;
+ ngx_conf_init_uint_value(peer[i].weight, 1);
+ peer[i].current_weight = peer[i].weight;
+ ngx_conf_init_uint_value(peer[i].max_fails,
+ conf->upstream.max_fails);
+ ngx_conf_init_value(peer[i].fail_timeout,
+ conf->upstream.fail_timeout);
}
+
}
ngx_conf_merge_path_value(conf->upstream.temp_path,
diff --git a/src/http/modules/ngx_http_gzip_filter_module.c b/src/http/modules/ngx_http_gzip_filter_module.c
index a08f31cb5..26c164990 100644
--- a/src/http/modules/ngx_http_gzip_filter_module.c
+++ b/src/http/modules/ngx_http_gzip_filter_module.c
@@ -1087,7 +1087,7 @@ ngx_http_gzip_merge_conf(ngx_conf_t *cf, void *parent, void *child)
ngx_conf_merge_bufs_value(conf->bufs, prev->bufs, 4, ngx_pagesize);
- ngx_conf_merge_unsigned_value(conf->http_version, prev->http_version,
+ ngx_conf_merge_uint_value(conf->http_version, prev->http_version,
NGX_HTTP_VERSION_11);
ngx_conf_merge_bitmask_value(conf->proxied, prev->proxied,
(NGX_CONF_BITMASK_SET|NGX_HTTP_GZIP_PROXIED_OFF));
diff --git a/src/http/modules/ngx_http_headers_filter_module.c b/src/http/modules/ngx_http_headers_filter_module.c
index 8ced8e024..8065742a0 100644
--- a/src/http/modules/ngx_http_headers_filter_module.c
+++ b/src/http/modules/ngx_http_headers_filter_module.c
@@ -103,9 +103,12 @@ ngx_http_headers_filter(ngx_http_request_t *r)
ngx_http_header_val_t *h;
ngx_http_headers_conf_t *conf;
- if ((r->headers_out.status != NGX_HTTP_OK
- && r->headers_out.status != NGX_HTTP_NOT_MODIFIED)
- || r != r->main)
+ if (r != r->main
+ || (r->headers_out.status != NGX_HTTP_OK
+ && r->headers_out.status != NGX_HTTP_NO_CONTENT
+ && r->headers_out.status != NGX_HTTP_MOVED_PERMANENTLY
+ && r->headers_out.status != NGX_HTTP_MOVED_TEMPORARILY
+ && r->headers_out.status != NGX_HTTP_NOT_MODIFIED))
{
return ngx_http_next_header_filter(r);
}
diff --git a/src/http/modules/ngx_http_log_module.c b/src/http/modules/ngx_http_log_module.c
index 5e1636385..f85a6c829 100644
--- a/src/http/modules/ngx_http_log_module.c
+++ b/src/http/modules/ngx_http_log_module.c
@@ -478,7 +478,7 @@ static u_char *
ngx_http_log_request_length(ngx_http_request_t *r, u_char *buf,
ngx_http_log_op_t *op)
{
- return ngx_sprintf(buf, "%z", r->request_length);
+ return ngx_sprintf(buf, "%O", r->request_length);
}
diff --git a/src/http/modules/ngx_http_memcached_module.c b/src/http/modules/ngx_http_memcached_module.c
index 5b07dbc52..000622d94 100644
--- a/src/http/modules/ngx_http_memcached_module.c
+++ b/src/http/modules/ngx_http_memcached_module.c
@@ -560,7 +560,7 @@ ngx_http_memcached_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|NGX_HTTP_UPSTREAM_FT_ERROR
|NGX_HTTP_UPSTREAM_FT_TIMEOUT));
- ngx_conf_merge_unsigned_value(conf->upstream.max_fails,
+ ngx_conf_merge_uint_value(conf->upstream.max_fails,
prev->upstream.max_fails, 1);
ngx_conf_merge_sec_value(conf->upstream.fail_timeout,
diff --git a/src/http/modules/ngx_http_proxy_module.c b/src/http/modules/ngx_http_proxy_module.c
index f14151ae8..ff5b129a8 100644
--- a/src/http/modules/ngx_http_proxy_module.c
+++ b/src/http/modules/ngx_http_proxy_module.c
@@ -1520,6 +1520,7 @@ ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
uintptr_t *code;
ngx_str_t *header;
ngx_uint_t i, j;
+ ngx_peer_t *peer;
ngx_array_t hide_headers;
ngx_keyval_t *src, *s, *h;
ngx_hash_key_t *hk;
@@ -1647,19 +1648,21 @@ ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|NGX_HTTP_UPSTREAM_FT_ERROR
|NGX_HTTP_UPSTREAM_FT_TIMEOUT));
- ngx_conf_merge_unsigned_value(conf->upstream.max_fails,
+ ngx_conf_merge_uint_value(conf->upstream.max_fails,
prev->upstream.max_fails, 1);
ngx_conf_merge_sec_value(conf->upstream.fail_timeout,
prev->upstream.fail_timeout, 10);
- if (conf->upstream_peers && !conf->upstream_peers->balanced) {
+ if (conf->upstream_peers) {
+ peer = conf->upstream_peers->peers->peer;
for (i = 0; i < conf->upstream_peers->peers->number; i++) {
- conf->upstream_peers->peers->peer[i].weight = 1;
- conf->upstream_peers->peers->peer[i].max_fails =
- conf->upstream.max_fails;
- conf->upstream_peers->peers->peer[i].fail_timeout =
- conf->upstream.fail_timeout;
+ ngx_conf_init_uint_value(peer[i].weight, 1);
+ peer[i].current_weight = peer[i].weight;
+ ngx_conf_init_uint_value(peer[i].max_fails,
+ conf->upstream.max_fails);
+ ngx_conf_init_value(peer[i].fail_timeout,
+ conf->upstream.fail_timeout);
}
}
diff --git a/src/http/modules/ngx_http_realip_module.c b/src/http/modules/ngx_http_realip_module.c
index 210bbf6f3..3940ee442 100644
--- a/src/http/modules/ngx_http_realip_module.c
+++ b/src/http/modules/ngx_http_realip_module.c
@@ -243,7 +243,7 @@ ngx_http_realip_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
conf->from = prev->from;
}
- ngx_conf_merge_unsigned_value(conf->xfwd, prev->xfwd, 0);
+ ngx_conf_merge_uint_value(conf->xfwd, prev->xfwd, 0);
return NGX_CONF_OK;
}
diff --git a/src/http/modules/ngx_http_rewrite_module.c b/src/http/modules/ngx_http_rewrite_module.c
index c557314ee..88988bdf0 100644
--- a/src/http/modules/ngx_http_rewrite_module.c
+++ b/src/http/modules/ngx_http_rewrite_module.c
@@ -245,7 +245,7 @@ ngx_http_rewrite_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
ngx_conf_merge_value(conf->log, prev->log, 0);
ngx_conf_merge_value(conf->uninitialized_variable_warn,
prev->uninitialized_variable_warn, 1);
- ngx_conf_merge_unsigned_value(conf->stack_size, prev->stack_size, 10);
+ ngx_conf_merge_uint_value(conf->stack_size, prev->stack_size, 10);
if (conf->codes == NULL) {
return NGX_CONF_OK;
diff --git a/src/http/modules/ngx_http_userid_filter_module.c b/src/http/modules/ngx_http_userid_filter_module.c
index 92c53f83e..bdad35dd7 100644
--- a/src/http/modules/ngx_http_userid_filter_module.c
+++ b/src/http/modules/ngx_http_userid_filter_module.c
@@ -670,8 +670,8 @@ ngx_http_userid_merge_conf(ngx_conf_t *cf, void *parent, void *child)
ngx_http_userid_conf_t *prev = parent;
ngx_http_userid_conf_t *conf = child;
- ngx_conf_merge_unsigned_value(conf->enable, prev->enable,
- NGX_HTTP_USERID_OFF);
+ ngx_conf_merge_uint_value(conf->enable, prev->enable,
+ NGX_HTTP_USERID_OFF);
ngx_conf_merge_str_value(conf->name, prev->name, "uid");
ngx_conf_merge_str_value(conf->domain, prev->domain, "");
diff --git a/src/http/modules/perl/ngx_http_perl_module.c b/src/http/modules/perl/ngx_http_perl_module.c
index 91a9c85ca..bf976e9f0 100644
--- a/src/http/modules/perl/ngx_http_perl_module.c
+++ b/src/http/modules/perl/ngx_http_perl_module.c
@@ -833,9 +833,9 @@ ngx_http_perl_init_main_conf(ngx_conf_t *cf, void *conf)
ngx_http_perl_main_conf_t *pmcf = conf;
#if (NGX_HAVE_PERL_CLONE || NGX_HAVE_PERL_MULTIPLICITY)
- ngx_conf_init_unsigned_value(pmcf->interp_max, 10);
+ ngx_conf_init_uint_value(pmcf->interp_max, 10);
#else
- ngx_conf_init_unsigned_value(pmcf->interp_max, 1);
+ ngx_conf_init_uint_value(pmcf->interp_max, 1);
#endif
pmcf->free_perls = ngx_pcalloc(cf->pool,
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index ca963abe4..b417f41c6 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -242,7 +242,7 @@ static ngx_command_t ngx_http_core_commands[] = {
{ ngx_string("client_max_body_size"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
- ngx_conf_set_size_slot,
+ ngx_conf_set_off_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_core_loc_conf_t, client_max_body_size),
NULL },
@@ -634,6 +634,12 @@ ngx_http_core_run_phases(ngx_http_request_t *r)
}
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);
return;
}
@@ -690,15 +696,15 @@ ngx_http_find_location_config(ngx_http_request_t *r)
ngx_http_update_location_config(r);
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
- "http cl:%z max:%uz",
+ "http cl:%O max:%O",
r->headers_in.content_length_n, clcf->client_max_body_size);
if (r->headers_in.content_length_n != -1
&& clcf->client_max_body_size
- && clcf->client_max_body_size < (size_t) r->headers_in.content_length_n)
+ && clcf->client_max_body_size < r->headers_in.content_length_n)
{
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
- "client intented to send too large body: %z bytes",
+ "client intented to send too large body: %O bytes",
r->headers_in.content_length_n);
return NGX_HTTP_REQUEST_ENTITY_TOO_LARGE;
@@ -2015,7 +2021,7 @@ ngx_http_core_create_loc_conf(ngx_conf_t *cf)
* lcf->alias = 0;
*/
- lcf->client_max_body_size = NGX_CONF_UNSET_SIZE;
+ lcf->client_max_body_size = NGX_CONF_UNSET;
lcf->client_body_buffer_size = NGX_CONF_UNSET_SIZE;
lcf->client_body_timeout = NGX_CONF_UNSET_MSEC;
lcf->satisfy_any = NGX_CONF_UNSET;
@@ -2086,12 +2092,12 @@ ngx_http_core_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
conf->post_action = prev->post_action;
}
- ngx_conf_merge_unsigned_value(conf->types_hash_max_size,
- prev->types_hash_max_size, 1024);
+ ngx_conf_merge_uint_value(conf->types_hash_max_size,
+ prev->types_hash_max_size, 1024);
- ngx_conf_merge_unsigned_value(conf->types_hash_bucket_size,
- prev->types_hash_bucket_size,
- ngx_cacheline_size);
+ ngx_conf_merge_uint_value(conf->types_hash_bucket_size,
+ prev->types_hash_bucket_size,
+ ngx_cacheline_size);
conf->types_hash_bucket_size = ngx_align(conf->types_hash_bucket_size,
ngx_cacheline_size);
@@ -2175,7 +2181,7 @@ ngx_http_core_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
ngx_conf_merge_str_value(conf->default_type,
prev->default_type, "text/plain");
- ngx_conf_merge_size_value(conf->client_max_body_size,
+ ngx_conf_merge_off_value(conf->client_max_body_size,
prev->client_max_body_size, 1 * 1024 * 1024);
ngx_conf_merge_size_value(conf->client_body_buffer_size,
prev->client_body_buffer_size,
@@ -2451,6 +2457,11 @@ ngx_http_core_server_name(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
ch = value[i].data[0];
+ if (value[i].len == 1 && ch == '*') {
+ cscf->wildcard = 1;
+ continue;
+ }
+
if (value[i].len == 0
|| (ch == '*' && (value[i].len < 3 || value[i].data[1] != '.'))
|| (ch == '.' && value[i].len < 2))
diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h
index 4f7823d3a..661f1b9e1 100644
--- a/src/http/ngx_http_core_module.h
+++ b/src/http/ngx_http_core_module.h
@@ -116,6 +116,8 @@ typedef struct {
ngx_flag_t optimize_server_names;
ngx_flag_t ignore_invalid_headers;
+
+ ngx_uint_t wildcard; /* unsigned wildcard:1 */
} ngx_http_core_srv_conf_t;
@@ -213,7 +215,8 @@ struct ngx_http_core_loc_conf_s {
ngx_hash_t types_hash;
ngx_str_t default_type;
- size_t client_max_body_size; /* client_max_body_size */
+ off_t client_max_body_size; /* client_max_body_size */
+
size_t client_body_buffer_size; /* client_body_buffer_size */
size_t send_lowat; /* send_lowat */
size_t postpone_output; /* postpone_output */
diff --git a/src/http/ngx_http_header_filter_module.c b/src/http/ngx_http_header_filter_module.c
index 36ed6e1f1..c6ecd3a3c 100644
--- a/src/http/ngx_http_header_filter_module.c
+++ b/src/http/ngx_http_header_filter_module.c
@@ -84,7 +84,7 @@ static ngx_str_t ngx_http_status_lines[] = {
ngx_string("406 Not Acceptable"),
ngx_null_string, /* "407 Proxy Authentication Required" */
ngx_string("408 Request Time-out"),
- ngx_null_string, /* "409 Conflict" */
+ ngx_string("409 Conflict"),
ngx_string("410 Gone"),
ngx_string("411 Length Required"),
ngx_null_string, /* "412 Precondition Failed" */
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index 5b947ff76..bf3b0edf8 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -1235,7 +1235,7 @@ ngx_http_process_request_header(ngx_http_request_t *r)
if (r->headers_in.content_length) {
r->headers_in.content_length_n =
- ngx_atosz(r->headers_in.content_length->value.data,
+ ngx_atoof(r->headers_in.content_length->value.data,
r->headers_in.content_length->value.len);
if (r->headers_in.content_length_n == NGX_ERROR) {
@@ -1395,6 +1395,13 @@ ngx_http_find_virtual_server(ngx_http_request_t *r,
}
}
+ cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
+
+ if (cscf->wildcard) {
+ r->server_name.len = len;
+ r->server_name.data = host;
+ }
+
return;
found:
diff --git a/src/http/ngx_http_request.h b/src/http/ngx_http_request.h
index 0bec20446..b2d41849c 100644
--- a/src/http/ngx_http_request.h
+++ b/src/http/ngx_http_request.h
@@ -192,7 +192,7 @@ typedef struct {
ngx_array_t cookies;
size_t host_name_len;
- ssize_t content_length_n;
+ off_t content_length_n;
time_t keep_alive_n;
unsigned connection_type:2;
@@ -250,7 +250,7 @@ typedef struct {
ngx_temp_file_t *temp_file;
ngx_chain_t *bufs;
ngx_buf_t *buf;
- size_t rest;
+ off_t rest;
ngx_chain_t *to_write;
ngx_http_client_body_handler_pt post_handler;
} ngx_http_request_body_t;
@@ -366,7 +366,7 @@ struct ngx_http_request_s {
/* used to learn the Apache compatible response length without a header */
size_t header_size;
- size_t request_length;
+ off_t request_length;
void **err_ctx;
ngx_uint_t err_status;
diff --git a/src/http/ngx_http_request_body.c b/src/http/ngx_http_request_body.c
index 605c8ad52..c6fa3fc09 100644
--- a/src/http/ngx_http_request_body.c
+++ b/src/http/ngx_http_request_body.c
@@ -30,7 +30,8 @@ ngx_int_t
ngx_http_read_client_request_body(ngx_http_request_t *r,
ngx_http_client_body_handler_pt post_handler)
{
- ssize_t size, preread;
+ size_t preread;
+ ssize_t size;
ngx_buf_t *b;
ngx_chain_t *cl, **next;
ngx_http_request_body_t *rb;
@@ -95,7 +96,7 @@ ngx_http_read_client_request_body(ngx_http_request_t *r,
/* the whole request body was pre-read */
- r->header_in->pos += r->headers_in.content_length_n;
+ r->header_in->pos += (size_t) r->headers_in.content_length_n;
r->request_length += r->headers_in.content_length_n;
if (r->request_body_in_file_only) {
@@ -143,8 +144,8 @@ ngx_http_read_client_request_body(ngx_http_request_t *r,
size = clcf->client_body_buffer_size;
size += size >> 2;
- if (rb->rest < (size_t) size) {
- size = rb->rest;
+ if (rb->rest < size) {
+ size = (ssize_t) rb->rest;
if (r->request_body_in_single_buf) {
size += preread;
@@ -242,7 +243,7 @@ ngx_http_do_read_client_request_body(ngx_http_request_t *r)
size = rb->buf->end - rb->buf->last;
if (size > rb->rest) {
- size = rb->rest;
+ size = (size_t) rb->rest;
}
n = c->recv(c, rb->buf->last, size);
@@ -429,7 +430,7 @@ ngx_http_discard_body(ngx_http_request_t *r)
r->headers_in.content_length_n -= size;
} else {
- r->header_in->pos += r->headers_in.content_length_n;
+ r->header_in->pos += (size_t) r->headers_in.content_length_n;
r->headers_in.content_length_n = 0;
return NGX_OK;
}
@@ -468,7 +469,8 @@ ngx_http_read_discarded_body_handler(ngx_http_request_t *r)
static ngx_int_t
ngx_http_read_discarded_body(ngx_http_request_t *r)
{
- ssize_t size, n;
+ size_t size;
+ ssize_t n;
u_char buffer[NGX_HTTP_DISCARD_BUFFER_SIZE];
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
@@ -478,12 +480,9 @@ ngx_http_read_discarded_body(ngx_http_request_t *r)
return NGX_OK;
}
-
- size = r->headers_in.content_length_n;
-
- if (size > NGX_HTTP_DISCARD_BUFFER_SIZE) {
- size = NGX_HTTP_DISCARD_BUFFER_SIZE;
- }
+ size = (r->headers_in.content_length_n > NGX_HTTP_DISCARD_BUFFER_SIZE) ?
+ NGX_HTTP_DISCARD_BUFFER_SIZE:
+ (size_t) r->headers_in.content_length_n;
n = r->connection->recv(r->connection, buffer, size);
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
index a8c557a6e..782c14be9 100644
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -226,7 +226,7 @@ static ngx_command_t ngx_http_upstream_commands[] = {
NULL },
{ ngx_string("server"),
- NGX_HTTP_UPS_CONF|NGX_CONF_TAKE1,
+ NGX_HTTP_UPS_CONF|NGX_CONF_TAKE12,
ngx_http_upstream_server,
NGX_HTTP_SRV_CONF_OFFSET,
0,
@@ -2729,7 +2729,6 @@ ngx_http_upstream(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy)
}
uscf->peers->number = n;
- uscf->peers->weight = 1;
n = 0;
@@ -2750,6 +2749,8 @@ ngx_http_upstream_server(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
ngx_str_t *value;
ngx_url_t u;
+ ngx_int_t weight;
+ ngx_uint_t i;
ngx_peers_t **peers;
if (uscf->servers == NULL) {
@@ -2780,9 +2781,41 @@ ngx_http_upstream_server(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
return NGX_CONF_ERROR;
}
+ weight = 1;
+
+ if (cf->args->nelts == 3) {
+
+ value = &value[2];
+
+ if (ngx_strncmp(value->data, "weight=", 7) == 0) {
+
+ weight = ngx_atoi(&value->data[7], value->len - 7);
+
+ if (weight == NGX_ERROR || weight == 0) {
+ goto invalid;
+ }
+
+ } else {
+ goto invalid;
+ }
+ }
+
+ for (i = 0; i < u.peers->number; i++) {
+ u.peers->peer[i].weight = weight;
+ u.peers->peer[i].current_weight = weight;
+ u.peers->peer[i].max_fails = NGX_CONF_UNSET_UINT;
+ u.peers->peer[i].fail_timeout = NGX_CONF_UNSET;
+ }
+
*peers = u.peers;
return NGX_CONF_OK;
+
+invalid:
+
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "invalid parameter \"%V\"", value);
+
+ return NGX_CONF_ERROR;
}
@@ -2893,8 +2926,7 @@ ngx_http_upstream_init_main_conf(ngx_conf_t *cf, void *conf)
}
uscfp[i]->peers = ngx_inet_resolve_peer(cf, &uscfp[i]->host,
- uscfp[i]->port);
-
+ uscfp[i]->port);
if (uscfp[i]->peers == NULL) {
return NGX_CONF_ERROR;
}
@@ -2908,6 +2940,7 @@ ngx_http_upstream_init_main_conf(ngx_conf_t *cf, void *conf)
}
}
+
if (ngx_array_init(&headers_in, cf->temp_pool, 32, sizeof(ngx_hash_key_t))
!= NGX_OK)
{
diff --git a/src/http/ngx_http_upstream.h b/src/http/ngx_http_upstream.h
index 53705fc24..086d184b3 100644
--- a/src/http/ngx_http_upstream.h
+++ b/src/http/ngx_http_upstream.h
@@ -56,8 +56,6 @@ typedef struct {
ngx_str_t file_name;
ngx_uint_t line;
in_port_t port;
-
- ngx_uint_t balanced; /* unsigned balanced:1; */
} ngx_http_upstream_srv_conf_t;