Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nginx/nginx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/http
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2005-06-15 22:33:41 +0400
committerIgor Sysoev <igor@sysoev.ru>2005-06-15 22:33:41 +0400
commitb145b067e296fd0c72d764e36db7a97102045b2c (patch)
tree1604c71100a9ea0dc0be0f848ed7ed9dc7108843 /src/http
parente08f105e27475ea77f5ceb39fc76d9cb2ba078d1 (diff)
nginx-0.1.36-RELEASE importrelease-0.1.36
*) Change: if the request header has duplicate the "Host", "Connection", "Content-Length", or "Authorization" lines, then nginx now returns the 400 error. *) Change: the "post_accept_timeout" directive was canceled. *) Feature: the "default", "af=", "bl=", "deferred", and "bind" parameters of the "listen" directive. *) Feature: the FreeBSD accept filters support. *) Feature: the Linux TCP_DEFER_ACCEPT support. *) Bugfix: the ngx_http_autoindex_module did not support the file names in UTF-8. *) Bugfix: the new log file can be rotated by the -USR1 signal only if the reconfiguration by the -HUP signal was made twice.
Diffstat (limited to 'src/http')
-rw-r--r--src/http/modules/ngx_http_autoindex_module.c31
-rw-r--r--src/http/modules/ngx_http_charset_filter_module.c29
-rw-r--r--src/http/ngx_http.c37
-rw-r--r--src/http/ngx_http_core_module.c163
-rw-r--r--src/http/ngx_http_core_module.h22
-rw-r--r--src/http/ngx_http_request.c61
-rw-r--r--src/http/ngx_http_request.h3
7 files changed, 228 insertions, 118 deletions
diff --git a/src/http/modules/ngx_http_autoindex_module.c b/src/http/modules/ngx_http_autoindex_module.c
index 96ab81e48..ab4418f9b 100644
--- a/src/http/modules/ngx_http_autoindex_module.c
+++ b/src/http/modules/ngx_http_autoindex_module.c
@@ -217,6 +217,16 @@ ngx_http_autoindex_handler(ngx_http_request_t *r)
return ngx_http_autoindex_error(r, &dir, dname.data);
}
+ r->headers_out.status = NGX_HTTP_OK;
+ r->headers_out.content_type.len = sizeof("text/html") - 1;
+ r->headers_out.content_type.data = (u_char *) "text/html";
+
+ rc = ngx_http_send_header(r);
+
+ if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) {
+ return rc;
+ }
+
fname.len = 0;
#if (NGX_SUPPRESS_WARN)
fname.data = NULL;
@@ -334,6 +344,10 @@ ngx_http_autoindex_handler(ngx_http_request_t *r)
+ sizeof(" 28-Sep-1970 12:00 ") - 1
+ 19
+ 2;
+
+ if (r->utf8) {
+ len += entry[i].name.len - ngx_utf_length(&entry[i].name);
+ }
}
b = ngx_create_temp_buf(r->pool, len);
@@ -380,7 +394,11 @@ ngx_http_autoindex_handler(ngx_http_request_t *r)
b->last = ngx_cpystrn(b->last, entry[i].name.data,
NGX_HTTP_AUTOINDEX_NAME_LEN + 1);
- len = entry[i].name.len;
+ if (r->utf8) {
+ len = ngx_utf_length(&entry[i].name);
+ } else {
+ len = entry[i].name.len;
+ }
if (len > NGX_HTTP_AUTOINDEX_NAME_LEN) {
b->last = ngx_cpymem(b->last - 3, "..&gt;</a>",
@@ -426,17 +444,6 @@ ngx_http_autoindex_handler(ngx_http_request_t *r)
b->last = ngx_cpymem(b->last, tail, sizeof(tail) - 1);
- r->headers_out.status = NGX_HTTP_OK;
- r->headers_out.content_length_n = b->last - b->pos;
- r->headers_out.content_type.len = sizeof("text/html") - 1;
- r->headers_out.content_type.data = (u_char *) "text/html";
-
- rc = ngx_http_send_header(r);
-
- if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) {
- return rc;
- }
-
if (r->main == NULL) {
b->last_buf = 1;
}
diff --git a/src/http/modules/ngx_http_charset_filter_module.c b/src/http/modules/ngx_http_charset_filter_module.c
index 0c76a5f43..117281ca2 100644
--- a/src/http/modules/ngx_http_charset_filter_module.c
+++ b/src/http/modules/ngx_http_charset_filter_module.c
@@ -12,15 +12,17 @@
typedef struct {
char **tables;
ngx_str_t name;
- ngx_uint_t server; /* unsigned server:1; */
+
+ unsigned server:1;
+ unsigned utf8:1;
} ngx_http_charset_t;
typedef struct {
- ngx_int_t src;
- ngx_int_t dst;
- char *src2dst;
- char *dst2src;
+ ngx_int_t src;
+ ngx_int_t dst;
+ char *src2dst;
+ char *dst2src;
} ngx_http_charset_tables_t;
@@ -31,17 +33,17 @@ typedef struct {
typedef struct {
- ngx_flag_t enable;
- ngx_flag_t autodetect;
+ ngx_flag_t enable;
+ ngx_flag_t autodetect;
- ngx_int_t default_charset;
- ngx_int_t source_charset;
+ ngx_int_t default_charset;
+ ngx_int_t source_charset;
} ngx_http_charset_loc_conf_t;
typedef struct {
- ngx_int_t server;
- ngx_int_t client;
+ ngx_int_t server;
+ ngx_int_t client;
} ngx_http_charset_ctx_t;
@@ -183,6 +185,7 @@ ngx_http_charset_header_filter(ngx_http_request_t *r)
charsets = mcf->charsets.elts;
r->headers_out.charset = charsets[lcf->default_charset].name;
+ r->utf8 = charsets[lcf->default_charset].utf8;
if (lcf->default_charset == lcf->source_charset) {
return ngx_http_next_header_filter(r);
@@ -448,6 +451,10 @@ ngx_http_add_charset(ngx_array_t *charsets, ngx_str_t *name)
c->name = *name;
c->server = 0;
+ if (ngx_strcasecmp(name->data, "utf-8") == 0) {
+ c->utf8 = 1;
+ }
+
return i;
}
diff --git a/src/http/ngx_http.c b/src/http/ngx_http.c
index 0fb057568..0f6f2f1d4 100644
--- a/src/http/ngx_http.c
+++ b/src/http/ngx_http.c
@@ -66,8 +66,9 @@ static char *
ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
char *rv;
- ngx_uint_t mi, m, s, l, p, a, n;
- ngx_uint_t port_found, addr_found, virtual_names, key;
+ ngx_uint_t mi, m, s, l, p, a, n, key;
+ ngx_uint_t port_found, addr_found;
+ ngx_uint_t virtual_names, separate_binding;
ngx_conf_t pcf;
ngx_array_t in_ports;
ngx_listening_t *ls;
@@ -408,9 +409,9 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
* for this address:port
*/
- if (lscf[l].default_server) {
+ if (lscf[l].conf.default_server) {
- if (in_addr[a].default_server) {
+ if (in_addr[a].conf.default_server) {
ngx_log_error(NGX_LOG_ERR, cf->log, 0,
"the duplicate default server in %V:%d",
&lscf[l].file_name, lscf[l].line);
@@ -419,7 +420,7 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
}
in_addr[a].core_srv_conf = cscfp[s];
- in_addr[a].default_server = 1;
+ in_addr[a].conf.default_server = 1;
}
addr_found = 1;
@@ -449,8 +450,8 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
in_addr[a].names.elts = NULL;
in_addr[a].hash = NULL;
in_addr[a].wildcards.elts = NULL;
- in_addr[a].default_server = lscf[l].default_server;
in_addr[a].core_srv_conf = cscfp[s];
+ in_addr[a].conf = lscf[l].conf;
if (ngx_http_add_names(cf, &in_addr[a], cscfp[s])
!= NGX_OK)
@@ -518,6 +519,8 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
in_port = in_ports.elts;
for (p = 0; p < in_ports.nelts; p++) {
+ separate_binding = 0;
+
/*
* check whether all name-based servers have the same configuraiton
* as the default server, or some servers restrict the host names
@@ -526,6 +529,10 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
in_addr = in_port[p].addrs.elts;
for (a = 0; a < in_port[p].addrs.nelts; a++) {
+ if (in_addr[a].conf.bind) {
+ separate_binding = 1;
+ }
+
virtual_names = 0;
name = in_addr[a].names.elts;
@@ -608,7 +615,7 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
* to the "*:port" only and ignore the other bindings
*/
- if (in_addr[a - 1].addr == INADDR_ANY) {
+ if (in_addr[a - 1].addr == INADDR_ANY && !separate_binding) {
a--;
} else {
@@ -624,15 +631,13 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
return NGX_CONF_ERROR;
}
- ls->backlog = -1;
-
ls->addr_ntop = 1;
ls->handler = ngx_http_init_connection;
cscf = in_addr[a].core_srv_conf;
ls->pool_size = cscf->connection_pool_size;
- ls->post_accept_timeout = cscf->post_accept_timeout;
+ ls->post_accept_timeout = cscf->client_header_timeout;
clcf = cscf->ctx->loc_conf[ngx_http_core_module.ctx_index];
ls->log = clcf->err_log;
@@ -644,6 +649,16 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
}
#endif
+ ls->backlog = in_addr[a].conf.backlog;
+
+#if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER)
+ ls->accept_filter = in_addr[a].conf.accept_filter;
+#endif
+
+#if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT)
+ ls->deferred_accept = in_addr[a].conf.deferred_accept;
+#endif
+
ls->ctx = ctx;
if (in_port[p].addrs.nelts > 1) {
@@ -766,8 +781,8 @@ ngx_http_add_address(ngx_conf_t *cf, ngx_http_in_port_t *in_port,
in_addr->names.elts = NULL;
in_addr->hash = NULL;
in_addr->wildcards.elts = NULL;
- in_addr->default_server = lscf->default_server;
in_addr->core_srv_conf = cscf;
+ in_addr->conf = lscf->conf;
#if (NGX_DEBUG)
{
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index 02795799a..1d399704f 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -102,13 +102,6 @@ static ngx_command_t ngx_http_core_commands[] = {
offsetof(ngx_http_core_srv_conf_t, connection_pool_size),
NULL },
- { ngx_string("post_accept_timeout"),
- NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
- ngx_conf_set_msec_slot,
- NGX_HTTP_SRV_CONF_OFFSET,
- offsetof(ngx_http_core_srv_conf_t, post_accept_timeout),
- NULL },
-
{ ngx_string("request_pool_size"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
ngx_conf_set_size_slot,
@@ -160,9 +153,9 @@ static ngx_command_t ngx_http_core_commands[] = {
{ ngx_string("listen"),
#if 0
- NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_1MORE,
#else
- NGX_HTTP_SRV_CONF|NGX_CONF_TAKE12,
+ NGX_HTTP_SRV_CONF|NGX_CONF_1MORE,
#endif
ngx_http_core_listen,
NGX_HTTP_SRV_CONF_OFFSET,
@@ -1592,7 +1585,6 @@ ngx_http_core_create_srv_conf(ngx_conf_t *cf)
}
cscf->connection_pool_size = NGX_CONF_UNSET_SIZE;
- cscf->post_accept_timeout = NGX_CONF_UNSET_MSEC;
cscf->request_pool_size = NGX_CONF_UNSET_SIZE;
cscf->client_header_timeout = NGX_CONF_UNSET_MSEC;
cscf->client_header_buffer_size = NGX_CONF_UNSET_SIZE;
@@ -1621,6 +1613,8 @@ ngx_http_core_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
return NGX_CONF_ERROR;
}
+ ngx_memzero(ls, sizeof(ngx_http_listen_t));
+
ls->addr = INADDR_ANY;
#if (NGX_WIN32)
ls->port = 80;
@@ -1629,7 +1623,6 @@ ngx_http_core_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
ls->port = (getuid() == 0) ? 80 : 8000;
#endif
ls->family = AF_INET;
- ls->default_server = 0;
}
if (conf->server_names.nelts == 0) {
@@ -1662,8 +1655,6 @@ ngx_http_core_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
ngx_conf_merge_size_value(conf->connection_pool_size,
prev->connection_pool_size, 256);
- ngx_conf_merge_msec_value(conf->post_accept_timeout,
- prev->post_accept_timeout, 60000);
ngx_conf_merge_size_value(conf->request_pool_size,
prev->request_pool_size, 4096);
ngx_conf_merge_msec_value(conf->client_header_timeout,
@@ -1859,89 +1850,145 @@ ngx_http_core_merge_loc_conf(ngx_conf_t *cf,
}
+/* AF_INET only */
+
static char *
ngx_http_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
ngx_http_core_srv_conf_t *scf = conf;
- u_char *addr;
- ngx_int_t port;
- ngx_uint_t p;
- ngx_str_t *args;
- struct hostent *h;
- ngx_http_listen_t *ls;
+ char *err;
+ ngx_str_t *value;
+ ngx_uint_t n;
+ struct hostent *h;
+ ngx_http_listen_t *ls;
+ ngx_inet_upstream_t inet_upstream;
/*
* TODO: check duplicate 'listen' directives,
* add resolved name to server names ???
*/
+ value = cf->args->elts;
+
+ ngx_memzero(&inet_upstream, sizeof(ngx_inet_upstream_t));
+
+ inet_upstream.url = value[1];
+ inet_upstream.port_only = 1;
+
+ err = ngx_inet_parse_host_port(&inet_upstream);
+
+ if (err) {
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "%s in \"%V\" of the \"listen\" directive",
+ err, &inet_upstream.url);
+ return NGX_CONF_ERROR;
+ }
+
ls = ngx_array_push(&scf->listen);
if (ls == NULL) {
return NGX_CONF_ERROR;
}
- /* AF_INET only */
+ ngx_memzero(ls, sizeof(ngx_http_listen_t));
ls->family = AF_INET;
+ ls->port = (in_port_t) (inet_upstream.default_port ?
+ 80 : inet_upstream.port);
ls->file_name = cf->conf_file->file.name;
ls->line = cf->conf_file->line;
- ls->default_server = 0;
+ ls->conf.backlog = -1;
- args = cf->args->elts;
- addr = args[1].data;
+ if (inet_upstream.host.len) {
+ inet_upstream.host.data[inet_upstream.host.len] = '\0';
- for (p = 0; p < args[1].len; p++) {
- if (addr[p] == ':') {
- addr[p++] = '\0';
- break;
+ ls->addr = inet_addr((const char *) inet_upstream.host.data);
+
+ if (ls->addr == INADDR_NONE) {
+ h = gethostbyname((const char *) inet_upstream.host.data);
+
+ if (h == NULL || h->h_addr_list[0] == NULL) {
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "can not resolve host \"%s\" "
+ "in the \"listen\" directive",
+ inet_upstream.host.data);
+ return NGX_CONF_ERROR;
+ }
+
+ ls->addr = *(in_addr_t *)(h->h_addr_list[0]);
}
- }
- if (p == args[1].len) {
- /* no ":" in the "listen" */
- p = 0;
+ } else {
+ ls->addr = INADDR_ANY;
}
- port = ngx_atoi(&addr[p], args[1].len - p);
-
- if (port == NGX_ERROR && p == 0) {
+ if (cf->args->nelts == 2) {
+ return NGX_CONF_OK;
+ }
- /* "listen host" */
- ls->port = 80;
+ if (ngx_strcmp(value[2].data, "default") == 0) {
+ ls->conf.default_server = 1;
+ n = 3;
+ } else {
+ n = 2;
+ }
- } else if ((port == NGX_ERROR && p != 0) /* "listen host:NONNUMBER" */
- || (port < 1 || port > 65536)) { /* "listen 99999" */
+ for ( /* void */ ; n < cf->args->nelts; n++) {
- ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
- "invalid port \"%s\" in \"%V\" directive, "
- "it must be a number between 1 and 65535",
- &addr[p], &cmd->name);
+ if (ls->conf.default_server == 0) {
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "\"%V\" parameter can be specified for "
+ "the default \"listen\" directive only",
+ &value[n]);
+ return NGX_CONF_ERROR;
+ }
- return NGX_CONF_ERROR;
+ if (ngx_strcmp(value[n].data, "bind") == 0) {
+ ls->conf.bind = 1;
+ continue;
+ }
- } else if (p == 0) {
- ls->addr = INADDR_ANY;
- ls->port = (in_port_t) port;
- return NGX_CONF_OK;
+ if (ngx_strncmp(value[n].data, "bl=", 3) == 0) {
+ ls->conf.backlog = ngx_atoi(value[n].data + 3, value[n].len - 3);
+ ls->conf.bind = 1;
- } else {
- ls->port = (in_port_t) port;
- }
+ if (ls->conf.backlog == NGX_ERROR || ls->conf.backlog == 0) {
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "invalid backlog \"%V\"", &value[n]);
+ return NGX_CONF_ERROR;
+ }
- ls->addr = inet_addr((const char *) addr);
+ continue;
+ }
- if (ls->addr == INADDR_NONE) {
- h = gethostbyname((const char *) addr);
+ if (ngx_strncmp(value[n].data, "af=", 3) == 0) {
+#if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER)
+ ls->conf.accept_filter = (char *) &value[n].data[3];
+ ls->conf.bind = 1;
+#else
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "accept filters \"%V\" are not supported "
+ "on this platform, ignored",
+ &value[n]);
+#endif
+ continue;
+ }
- if (h == NULL || h->h_addr_list[0] == NULL) {
+ if (ngx_strcmp(value[n].data, "deferred") == 0) {
+#if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT)
+ ls->conf.deferred_accept = 1;
+ ls->conf.bind = 1;
+#else
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
- "can not resolve host \"%s\" "
- "in \"%V\" directive", addr, &cmd->name);
- return NGX_CONF_ERROR;
+ "the deferred accept is not supported "
+ "on this platform, ignored");
+#endif
+ continue;
}
- ls->addr = *(in_addr_t *)(h->h_addr_list[0]);
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "the invalid \"%V\" parameter", &value[n]);
+ return NGX_CONF_ERROR;
}
return NGX_CONF_OK;
diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h
index 14090b916..11640467e 100644
--- a/src/http/ngx_http_core_module.h
+++ b/src/http/ngx_http_core_module.h
@@ -14,13 +14,30 @@
typedef struct {
+ unsigned default_server:1;
+ unsigned bind:1;
+
+ int backlog;
+
+#if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER)
+ char *accept_filter;
+#endif
+#if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT)
+ ngx_uint_t deferred_accept;
+#endif
+
+} ngx_http_listen_conf_t;
+
+
+typedef struct {
in_addr_t addr;
in_port_t port;
int family;
+
ngx_str_t file_name;
ngx_int_t line;
- ngx_uint_t default_server; /* unsigned default_server:1; */
+ ngx_http_listen_conf_t conf;
} ngx_http_listen_t;
@@ -83,7 +100,6 @@ typedef struct {
ngx_bufs_t large_client_header_buffers;
- ngx_msec_t post_accept_timeout;
ngx_msec_t client_header_timeout;
ngx_uint_t restrict_host_names;
@@ -111,7 +127,7 @@ struct ngx_http_in_addr_s {
/* the default server configuration for this address:port */
ngx_http_core_srv_conf_t *core_srv_conf;
- ngx_uint_t default_server; /* unsigned default_server:1; */
+ ngx_http_listen_conf_t conf;
};
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index f04c17fa8..c3e1ab79e 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -22,6 +22,8 @@ static ngx_int_t ngx_http_alloc_large_header_buffer(ngx_http_request_t *r,
static ngx_int_t ngx_http_process_header_line(ngx_http_request_t *r,
ngx_table_elt_t *h, ngx_uint_t offset);
+static ngx_int_t ngx_http_process_unique_header_line(ngx_http_request_t *r,
+ ngx_table_elt_t *h, ngx_uint_t offset);
static ngx_int_t ngx_http_process_cookie(ngx_http_request_t *r,
ngx_table_elt_t *h, ngx_uint_t offset);
@@ -62,10 +64,10 @@ static char *ngx_http_client_errors[] = {
ngx_http_header_t ngx_http_headers_in[] = {
{ ngx_string("Host"), offsetof(ngx_http_headers_in_t, host),
- ngx_http_process_header_line },
+ ngx_http_process_unique_header_line },
{ ngx_string("Connection"), offsetof(ngx_http_headers_in_t, connection),
- ngx_http_process_header_line },
+ ngx_http_process_unique_header_line },
{ ngx_string("If-Modified-Since"),
offsetof(ngx_http_headers_in_t, if_modified_since),
@@ -79,7 +81,7 @@ ngx_http_header_t ngx_http_headers_in[] = {
{ ngx_string("Content-Length"),
offsetof(ngx_http_headers_in_t, content_length),
- ngx_http_process_header_line },
+ ngx_http_process_unique_header_line },
{ ngx_string("Content-Type"),
offsetof(ngx_http_headers_in_t, content_type),
@@ -104,7 +106,7 @@ ngx_http_header_t ngx_http_headers_in[] = {
{ ngx_string("Authorization"),
offsetof(ngx_http_headers_in_t, authorization),
- ngx_http_process_header_line },
+ ngx_http_process_unique_header_line },
{ ngx_string("Keep-Alive"), offsetof(ngx_http_headers_in_t, keep_alive),
ngx_http_process_header_line },
@@ -113,12 +115,6 @@ ngx_http_header_t ngx_http_headers_in[] = {
{ ngx_string("X-Forwarded-For"),
offsetof(ngx_http_headers_in_t, x_forwarded_for),
ngx_http_process_header_line },
-
- { ngx_string("X-Real-IP"), offsetof(ngx_http_headers_in_t, x_real_ip),
- ngx_http_process_header_line },
-
- { ngx_string("X-URL"), offsetof(ngx_http_headers_in_t, x_url),
- ngx_http_process_header_line },
#endif
#if (NGX_HTTP_HEADERS)
@@ -906,13 +902,13 @@ ngx_http_read_request_header(ngx_http_request_t *r)
return n;
}
- if (!rev->ready) {
- return NGX_AGAIN;
+ if (rev->ready) {
+ n = r->connection->recv(r->connection, r->header_in->last,
+ r->header_in->end - r->header_in->last);
+ } else {
+ n = NGX_AGAIN;
}
- n = r->connection->recv(r->connection, r->header_in->last,
- r->header_in->end - r->header_in->last);
-
if (n == NGX_AGAIN) {
if (!r->header_timeout_set) {
cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
@@ -1107,21 +1103,44 @@ ngx_http_process_header_line(ngx_http_request_t *r, ngx_table_elt_t *h,
static ngx_int_t
+ngx_http_process_unique_header_line(ngx_http_request_t *r, ngx_table_elt_t *h,
+ ngx_uint_t offset)
+{
+ ngx_table_elt_t **ph;
+
+ ph = (ngx_table_elt_t **) ((char *) &r->headers_in + offset);
+
+ if (*ph == NULL) {
+ *ph = h;
+ return NGX_OK;
+ }
+
+ ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
+ "client sent duplicate header line: \"%V: %V\"",
+ &h->key, &h->value);
+
+ ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
+
+ return NGX_ERROR;
+}
+
+
+static ngx_int_t
ngx_http_process_cookie(ngx_http_request_t *r, ngx_table_elt_t *h,
ngx_uint_t offset)
{
ngx_table_elt_t **cookie;
cookie = ngx_array_push(&r->headers_in.cookies);
- if (cookie == NULL) {
- ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
- ngx_http_close_connection(r->connection);
- return NGX_ERROR;
+ if (cookie) {
+ *cookie = h;
+ return NGX_OK;
}
- *cookie = h;
+ ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
+ ngx_http_close_connection(r->connection);
- return NGX_OK;
+ return NGX_ERROR;
}
diff --git a/src/http/ngx_http_request.h b/src/http/ngx_http_request.h
index e2f303322..470f58459 100644
--- a/src/http/ngx_http_request.h
+++ b/src/http/ngx_http_request.h
@@ -152,8 +152,6 @@ typedef struct {
#if (NGX_HTTP_PROXY)
ngx_table_elt_t *x_forwarded_for;
- ngx_table_elt_t *x_real_ip;
- ngx_table_elt_t *x_url;
#endif
#if (NGX_HTTP_HEADERS)
@@ -365,6 +363,7 @@ struct ngx_http_request_s {
unsigned internal:1;
unsigned closed:1;
unsigned done:1;
+ unsigned utf8:1;
unsigned main_filter_need_in_memory:1;
unsigned filter_need_in_memory:1;