Skip to content

Commit

Permalink
Changes with nginx 0.9.4 21 Jan 2011
Browse files Browse the repository at this point in the history
*) Feature: the "server_name" directive supports the $hostname variable.

*) Feature: 494 code for "Request Header Too Large" error.
  • Loading branch information
igorsysoev authored and kolbyjack committed Jan 21, 2011
1 parent 487d8fc commit e52b136
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 57 deletions.
9 changes: 8 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@

Changes with nginx 0.9.4 21 Jan 2011

*) Feature: the "server_name" directive supports the $hostname variable.

*) Feature: 494 code for "Request Header Too Large" error.


Changes with nginx 0.9.3 13 Dec 2010

*) Bugfix: if there was a single server for given IPv6 address:port
Expand Down Expand Up @@ -5028,7 +5035,7 @@ Changes with nginx 0.1.11 02 Dec 2004
Changes with nginx 0.1.10 26 Nov 2004

*) Bugfix: if the request without arguments contains "//", "/./",
"/../" or "%XX" then the lost character in the request line was
"/../" or "%XX" then the last character in the request line was
lost; the bug had appeared in 0.1.9.

*) Bugfix: the fix in 0.1.9 for the files bigger than 2G on Linux did
Expand Down
13 changes: 10 additions & 3 deletions CHANGES.ru
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@

Изменения в nginx 0.9.4 21.01.2011

*) Добавление: директива server_name поддерживает переменную $hostname.

*) Добавление: 494 код для ошибки "Request Header Too Large".


Изменения в nginx 0.9.3 13.12.2010

*) Исправление: если для пары адрес:порт описан только один сервер, то
выделения в регулярных выражениях в директиве server_name не
работали.
*) Исправление: если для пары IPv6-адрес:порт описан только один
сервер, то выделения в регулярных выражениях в директиве server_name
не работали.

*) Исправление: nginx не собирался под Solaris; ошибка появилась в
0.9.0.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2002-2010 Igor Sysoev
* Copyright (C) 2002-2011 Igor Sysoev
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
Expand Down
4 changes: 2 additions & 2 deletions src/core/nginx.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#define _NGINX_H_INCLUDED_


#define nginx_version 9003
#define NGINX_VERSION "0.9.3"
#define nginx_version 9004
#define NGINX_VERSION "0.9.4"
#define NGINX_VER "nginx/" NGINX_VERSION

#define NGINX_VAR "NGINX"
Expand Down
2 changes: 1 addition & 1 deletion src/event/ngx_event_openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ ngx_ssl_handshake(ngx_connection_t *c)
#if (NGX_DEBUG)
{
char buf[129], *s, *d;
#if OPENSSL_VERSION_NUMBER >= 0x1000000fL
#if OPENSSL_VERSION_NUMBER >= 0x10000000L
const
#endif
SSL_CIPHER *cipher;
Expand Down
3 changes: 2 additions & 1 deletion src/http/modules/ngx_http_fastcgi_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -1280,8 +1280,9 @@ ngx_http_fastcgi_process_header(ngx_http_request_t *r)
} else {
u->buffer.pos = u->buffer.start;
}
#else
u->buffer.pos = u->buffer.start;
#endif

u->buffer.last = u->buffer.pos;
f->large_stderr = 1;
}
Expand Down
4 changes: 2 additions & 2 deletions src/http/modules/ngx_http_not_modified_filter_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ ngx_http_not_modified_header_filter(ngx_http_request_t *r)
{
return ngx_http_next_header_filter(r);
}

if (r->headers_in.if_unmodified_since) {
return ngx_http_test_precondition(r);
}

if (r->headers_in.if_modified_since) {
return ngx_http_test_not_modified(r);
}
Expand Down
2 changes: 1 addition & 1 deletion src/http/modules/perl/nginx.pm
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ our @EXPORT = qw(
HTTP_INSUFFICIENT_STORAGE
);

our $VERSION = '0.9.3';
our $VERSION = '0.9.4';

require XSLoader;
XSLoader::load('nginx', $VERSION);
Expand Down
72 changes: 34 additions & 38 deletions src/http/ngx_http_core_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -789,11 +789,7 @@ ngx_http_handler(ngx_http_request_t *r)
if (!r->internal) {
switch (r->headers_in.connection_type) {
case 0:
if (r->http_version > NGX_HTTP_VERSION_10) {
r->keepalive = 1;
} else {
r->keepalive = 0;
}
r->keepalive = (r->http_version > NGX_HTTP_VERSION_10);
break;

case NGX_HTTP_CONNECTION_CLOSE:
Expand All @@ -805,13 +801,7 @@ ngx_http_handler(ngx_http_request_t *r)
break;
}

if (r->headers_in.content_length_n > 0) {
r->lingering_close = 1;

} else {
r->lingering_close = 0;
}

r->lingering_close = (r->headers_in.content_length_n > 0);
r->phase_handler = 0;

} else {
Expand Down Expand Up @@ -3000,6 +2990,7 @@ ngx_http_core_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
ngx_http_core_srv_conf_t *prev = parent;
ngx_http_core_srv_conf_t *conf = child;

ngx_str_t name;
ngx_http_server_name_t *sn;

/* TODO: it does not merge, it inits only */
Expand Down Expand Up @@ -3031,21 +3022,37 @@ ngx_http_core_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
ngx_conf_merge_value(conf->underscores_in_headers,
prev->underscores_in_headers, 0);

if (conf->server_name.data == NULL) {
ngx_str_set(&conf->server_name, "");

if (conf->server_names.nelts == 0) {
/* the array has 4 empty preallocated elements, so push can not fail */
sn = ngx_array_push(&conf->server_names);
if (sn == NULL) {
return NGX_CONF_ERROR;
}

#if (NGX_PCRE)
sn->regex = NULL;
#endif
sn->server = conf;
ngx_str_set(&sn->name, "");
}

sn = conf->server_names.elts;
name = sn[0].name;

#if (NGX_PCRE)
if (sn->regex) {
name.len++;
name.data--;
} else
#endif

if (name.data[0] == '.') {
name.len--;
name.data++;
}

conf->server_name.len = name.len;
conf->server_name.data = ngx_pstrdup(cf->pool, &name);
if (conf->server_name.data == NULL) {
return NGX_CONF_ERROR;
}

return NGX_CONF_OK;
}

Expand Down Expand Up @@ -3635,29 +3642,12 @@ ngx_http_core_server_name(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
ngx_http_core_srv_conf_t *cscf = conf;

u_char ch;
ngx_str_t *value, name;
ngx_str_t *value;
ngx_uint_t i;
ngx_http_server_name_t *sn;

value = cf->args->elts;

ch = value[1].data[0];

if (cscf->server_name.data == NULL) {
name = value[1];

if (ch == '.') {
name.len--;
name.data++;
}

cscf->server_name.len = name.len;
cscf->server_name.data = ngx_pstrdup(cf->pool, &name);
if (cscf->server_name.data == NULL) {
return NGX_CONF_ERROR;
}
}

for (i = 1; i < cf->args->nelts; i++) {

ch = value[i].data[0];
Expand Down Expand Up @@ -3692,7 +3682,13 @@ ngx_http_core_server_name(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
sn->regex = NULL;
#endif
sn->server = cscf;
sn->name = value[i];

if (ngx_strcasecmp(value[i].data, (u_char *) "$hostname") == 0) {
sn->name = cf->cycle->hostname;

} else {
sn->name = value[i];
}

if (value[i].data[0] != '~') {
ngx_strlow(sn->name.data, sn->name.data, sn->name.len);
Expand Down
9 changes: 7 additions & 2 deletions src/http/ngx_http_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -978,10 +978,13 @@ ngx_http_process_request_headers(ngx_event_t *rev)
if (rv == NGX_DECLINED) {
p = r->header_name_start;

r->lingering_close = 1;

if (p == NULL) {
ngx_log_error(NGX_LOG_INFO, c->log, 0,
"client sent too large request");
ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
ngx_http_finalize_request(r,
NGX_HTTP_REQUEST_HEADER_TOO_LARGE);
return;
}

Expand All @@ -995,7 +998,9 @@ ngx_http_process_request_headers(ngx_event_t *rev)
ngx_log_error(NGX_LOG_INFO, c->log, 0,
"client sent too long header line: \"%*s\"",
len, r->header_name_start);
ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);

ngx_http_finalize_request(r,
NGX_HTTP_REQUEST_HEADER_TOO_LARGE);
return;
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/http/ngx_http_request.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@
/* The special code to close connection without any response */
#define NGX_HTTP_CLOSE 444

#define NGX_HTTP_OWN_CODES 495
#define NGX_HTTP_NGINX_CODES 494

#define NGX_HTTP_REQUEST_HEADER_TOO_LARGE 494

#define NGX_HTTPS_CERT_ERROR 495
#define NGX_HTTPS_NO_CERT 496
Expand Down
20 changes: 16 additions & 4 deletions src/http/ngx_http_special_response.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,16 @@ static char ngx_http_error_416_page[] =
;


static char ngx_http_error_494_page[] =
"<html>" CRLF
"<head><title>400 Request Header Or Cookie Too Large</title></head>"
CRLF
"<body bgcolor=\"white\">" CRLF
"<center><h1>400 Bad Request</h1></center>" CRLF
"<center>Request Header Or Cookie Too Large</center>" CRLF
;


static char ngx_http_error_495_page[] =
"<html>" CRLF
"<head><title>400 The SSL certificate error</title></head>"
Expand Down Expand Up @@ -315,6 +325,7 @@ static ngx_str_t ngx_http_error_pages[] = {
#define NGX_HTTP_LAST_LEVEL_400 417
#define NGX_HTTP_LEVEL_400 (NGX_HTTP_LAST_LEVEL_400 - 400)

ngx_string(ngx_http_error_494_page), /* 494, request header too large */
ngx_string(ngx_http_error_495_page), /* 495, https certificate error */
ngx_string(ngx_http_error_496_page), /* 496, https no certificate */
ngx_string(ngx_http_error_497_page), /* 497, http to https */
Expand Down Expand Up @@ -429,17 +440,18 @@ ngx_http_special_response_handler(ngx_http_request_t *r, ngx_int_t error)
err = error - NGX_HTTP_BAD_REQUEST + NGX_HTTP_LEVEL_200
+ NGX_HTTP_LEVEL_300;

} else if (error >= NGX_HTTP_OWN_CODES
} else if (error >= NGX_HTTP_NGINX_CODES
&& error < NGX_HTTP_LAST_LEVEL_500)
{
/* 49X, 5XX */
err = error - NGX_HTTP_OWN_CODES + NGX_HTTP_LEVEL_200
+ NGX_HTTP_LEVEL_300
+ NGX_HTTP_LEVEL_400;
err = error - NGX_HTTP_NGINX_CODES + NGX_HTTP_LEVEL_200
+ NGX_HTTP_LEVEL_300
+ NGX_HTTP_LEVEL_400;
switch (error) {
case NGX_HTTP_TO_HTTPS:
case NGX_HTTPS_CERT_ERROR:
case NGX_HTTPS_NO_CERT:
case NGX_HTTP_REQUEST_HEADER_TOO_LARGE:
r->err_status = NGX_HTTP_BAD_REQUEST;
break;
}
Expand Down

0 comments on commit e52b136

Please sign in to comment.