nginx-0.1.35-RELEASE import
*) Feature: the "working_directory" directive.
*) Feature: the "port_in_redirect" directive.
*) Bugfix: the segmentation fault was occurred if the backend response
header was in several packets; the bug had appeared in 0.1.29.
*) Bugfix: if more than 10 servers were configured or some server did
not use the "listen" directive, then the segmentation fault was
occurred on the start.
*) Bugfix: the segmentation fault might occur if the response was
bigger than the temporary file.
*) Bugfix: nginx returned the 400 response on requests like
"GET http://www.domain.com/uri HTTP/1.0"; the bug had appeared in
0.1.28.
diff --git a/src/http/modules/ngx_http_proxy_module.c b/src/http/modules/ngx_http_proxy_module.c
index 0211dab..83625be 100644
--- a/src/http/modules/ngx_http_proxy_module.c
+++ b/src/http/modules/ngx_http_proxy_module.c
@@ -1013,6 +1013,10 @@
return NGX_OK;
}
+ if (rc == NGX_AGAIN) {
+ return NGX_AGAIN;
+ }
+
/* there was error while a header line parsing */
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
diff --git a/src/http/ngx_http.c b/src/http/ngx_http.c
index 94f718d..0fb0575 100644
--- a/src/http/ngx_http.c
+++ b/src/http/ngx_http.c
@@ -360,7 +360,7 @@
* to quickly find the server core module configuration at run-time
*/
- if (ngx_array_init(&in_ports, cf->pool, 10, sizeof(ngx_http_in_port_t))
+ if (ngx_array_init(&in_ports, cf->pool, 2, sizeof(ngx_http_in_port_t))
!= NGX_OK)
{
return NGX_CONF_ERROR;
@@ -434,6 +434,7 @@
if (inaddr == NULL) {
return NGX_CONF_ERROR;
}
+ in_addr = in_port[p].addrs.elts;
/*
* the INADDR_ANY must be the last resort
@@ -578,7 +579,7 @@
}
for (n = 0; n < cmcf->server_names_hash; n++) {
- if (ngx_array_init(&in_addr[a].hash[n], cf->pool, 5,
+ if (ngx_array_init(&in_addr[a].hash[n], cf->pool, 4,
sizeof(ngx_http_server_name_t)) != NGX_OK)
{
return NGX_CONF_ERROR;
@@ -595,6 +596,7 @@
if (s_name == NULL) {
return NGX_CONF_ERROR;
}
+ name = in_addr[a].names.elts;
*s_name = name[s];
}
@@ -748,7 +750,7 @@
ngx_http_in_addr_t *in_addr;
if (in_port->addrs.elts == NULL) {
- if (ngx_array_init(&in_port->addrs, cf->pool, 10,
+ if (ngx_array_init(&in_port->addrs, cf->pool, 4,
sizeof(ngx_http_in_addr_t)) != NGX_OK)
{
return NGX_ERROR;
@@ -794,7 +796,7 @@
ngx_http_server_name_t *server_names, *name;
if (in_addr->names.elts == NULL) {
- if (ngx_array_init(&in_addr->names, cf->pool, 10,
+ if (ngx_array_init(&in_addr->names, cf->pool, 4,
sizeof(ngx_http_server_name_t)) != NGX_OK)
{
return NGX_ERROR;
@@ -802,7 +804,7 @@
}
if (in_addr->wildcards.elts == NULL) {
- if (ngx_array_init(&in_addr->wildcards, cf->pool, 10,
+ if (ngx_array_init(&in_addr->wildcards, cf->pool, 1,
sizeof(ngx_http_server_name_t)) != NGX_OK)
{
return NGX_ERROR;
@@ -834,6 +836,7 @@
if (name == NULL) {
return NGX_ERROR;
}
+ server_names = cscf->server_names.elts;
*name = server_names[i];
}
diff --git a/src/http/ngx_http_config.h b/src/http/ngx_http_config.h
index 89110c0..d034351 100644
--- a/src/http/ngx_http_config.h
+++ b/src/http/ngx_http_config.h
@@ -8,7 +8,8 @@
#define _NGX_HTTP_CONFIG_H_INCLUDED_
-#include <ngx_alloc.h>
+#include <ngx_config.h>
+#include <ngx_core.h>
#include <ngx_http.h>
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index 42c8211..0279579 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -319,6 +319,13 @@
offsetof(ngx_http_core_loc_conf_t, reset_timedout_connection),
NULL },
+ { ngx_string("port_in_redirect"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
+ ngx_conf_set_flag_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_core_loc_conf_t, port_in_redirect),
+ NULL },
+
{ ngx_string("msie_padding"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
ngx_conf_set_flag_slot,
@@ -1113,10 +1120,10 @@
static char *
ngx_http_core_server(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy)
{
- int m;
char *rv;
void *mconf;
- ngx_conf_t save;
+ ngx_uint_t m;
+ ngx_conf_t pcf;
ngx_http_module_t *module;
ngx_http_conf_ctx_t *ctx, *http_ctx;
ngx_http_core_srv_conf_t *cscf, **cscfp;
@@ -1189,13 +1196,13 @@
/* parse inside server{} */
- save = *cf;
+ pcf = *cf;
cf->ctx = ctx;
cf->cmd_type = NGX_HTTP_SRV_CONF;
rv = ngx_conf_parse(cf, NULL);
- *cf = save;
+ *cf = pcf;
if (rv != NGX_CONF_OK) {
return rv;
@@ -1622,6 +1629,7 @@
ls->port = (getuid() == 0) ? 80 : 8000;
#endif
ls->family = AF_INET;
+ ls->default_server = 0;
}
if (conf->server_names.nelts == 0) {
@@ -1726,6 +1734,7 @@
lcf->lingering_time = NGX_CONF_UNSET_MSEC;
lcf->lingering_timeout = NGX_CONF_UNSET_MSEC;
lcf->reset_timedout_connection = NGX_CONF_UNSET;
+ lcf->port_in_redirect = NGX_CONF_UNSET;
lcf->msie_padding = NGX_CONF_UNSET;
return lcf;
@@ -1839,6 +1848,7 @@
ngx_conf_merge_value(conf->reset_timedout_connection,
prev->reset_timedout_connection, 0);
+ ngx_conf_merge_value(conf->port_in_redirect, prev->port_in_redirect, 1);
ngx_conf_merge_value(conf->msie_padding, prev->msie_padding, 1);
if (conf->open_files == NULL) {
@@ -1857,8 +1867,8 @@
u_char *addr;
ngx_int_t port;
ngx_uint_t p;
- struct hostent *h;
ngx_str_t *args;
+ struct hostent *h;
ngx_http_listen_t *ls;
/*
@@ -1874,9 +1884,9 @@
/* AF_INET only */
ls->family = AF_INET;
- ls->default_server = 0;
ls->file_name = cf->conf_file->file.name;
ls->line = cf->conf_file->line;
+ ls->default_server = 0;
args = cf->args->elts;
addr = args[1].data;
diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h
index 463c6b7..14090b9 100644
--- a/src/http/ngx_http_core_module.h
+++ b/src/http/ngx_http_core_module.h
@@ -20,7 +20,7 @@
ngx_str_t file_name;
ngx_int_t line;
- unsigned default_server:1;
+ ngx_uint_t default_server; /* unsigned default_server:1; */
} ngx_http_listen_t;
@@ -206,6 +206,7 @@
ngx_flag_t tcp_nopush; /* tcp_nopush */
ngx_flag_t tcp_nodelay; /* tcp_nodelay */
ngx_flag_t reset_timedout_connection; /* reset_timedout_connection */
+ ngx_flag_t port_in_redirect; /* port_in_redirect */
ngx_flag_t msie_padding; /* msie_padding */
ngx_array_t *error_pages; /* error_page */
diff --git a/src/http/ngx_http_header_filter_module.c b/src/http/ngx_http_header_filter_module.c
index a45f2e5..daf6c85 100644
--- a/src/http/ngx_http_header_filter_module.c
+++ b/src/http/ngx_http_header_filter_module.c
@@ -258,6 +258,8 @@
len += sizeof("Last-Modified: Mon, 28 Sep 1970 06:00:00 GMT" CRLF) - 1;
}
+ clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
+
if (r->headers_out.location
&& r->headers_out.location->value.len
&& r->headers_out.location->value.data[0] == '/')
@@ -270,7 +272,7 @@
+ r->server_name.len
+ r->headers_out.location->value.len + 2;
- if (r->port != 443) {
+ if (clcf->port_in_redirect && r->port != 443) {
len += r->port_text->len;
}
@@ -281,7 +283,7 @@
+ r->server_name.len
+ r->headers_out.location->value.len + 2;
- if (r->port != 80) {
+ if (clcf->port_in_redirect && r->port != 80) {
len += r->port_text->len;
}
}
@@ -291,8 +293,6 @@
len += sizeof("Transfer-Encoding: chunked" CRLF) - 1;
}
- clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
-
if (r->keepalive) {
len += sizeof("Connection: keep-alive" CRLF) - 1;
@@ -425,18 +425,20 @@
b->last = ngx_cpymem(b->last, r->server_name.data,
r->server_name.len);
+ if (clcf->port_in_redirect) {
#if (NGX_HTTP_SSL)
- if (r->connection->ssl) {
- if (r->port != 443) {
- b->last = ngx_cpymem(b->last, r->port_text->data,
- r->port_text->len);
- }
- } else
+ if (r->connection->ssl) {
+ if (r->port != 443) {
+ b->last = ngx_cpymem(b->last, r->port_text->data,
+ r->port_text->len);
+ }
+ } else
#endif
- {
- if (r->port != 80) {
- b->last = ngx_cpymem(b->last, r->port_text->data,
- r->port_text->len);
+ {
+ if (r->port != 80) {
+ b->last = ngx_cpymem(b->last, r->port_text->data,
+ r->port_text->len);
+ }
}
}
diff --git a/src/http/ngx_http_parse.c b/src/http/ngx_http_parse.c
index 027d9ef..302cd81 100644
--- a/src/http/ngx_http_parse.c
+++ b/src/http/ngx_http_parse.c
@@ -112,7 +112,7 @@
case sw_spaces_before_uri:
c = (u_char) (ch | 0x20);
- if (c >= 'a' && c <= 'f') {
+ if (c >= 'a' && c <= 'z') {
r->schema_start = p;
state = sw_schema;
break;
@@ -133,7 +133,7 @@
case sw_schema:
c = (u_char) (ch | 0x20);
- if (c >= 'a' && c <= 'f') {
+ if (c >= 'a' && c <= 'z') {
break;
}
@@ -171,7 +171,7 @@
case sw_host:
c = (u_char) (ch | 0x20);
- if (c >= 'a' && c <= 'f') {
+ if (c >= 'a' && c <= 'z') {
break;
}
@@ -215,7 +215,7 @@
case sw_after_slash_in_uri:
c = (u_char) (ch | 0x20);
- if (c >= 'a' && c <= 'f') {
+ if (c >= 'a' && c <= 'z') {
state = sw_check_uri;
break;
}
@@ -277,7 +277,7 @@
case sw_check_uri:
c = (u_char) (ch | 0x20);
- if (c >= 'a' && c <= 'f') {
+ if (c >= 'a' && c <= 'z') {
break;
}
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index 37a176a..f04c17f 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -1722,6 +1722,10 @@
ssize_t size;
ngx_event_t *rev;
+ if (r->main) {
+ return NGX_OK;
+ }
+
rev = r->connection->read;
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, rev->log, 0, "http set discard body");