2002-12-10 15:05:12 -03:00
|
|
|
|
2004-09-28 04:34:51 -04:00
|
|
|
/*
|
2004-09-29 12:00:49 -04:00
|
|
|
* Copyright (C) Igor Sysoev
|
2004-09-28 04:34:51 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2002-12-10 15:05:12 -03:00
|
|
|
#include <ngx_config.h>
|
|
|
|
#include <ngx_core.h>
|
|
|
|
#include <ngx_http.h>
|
2003-06-02 11:24:30 -04:00
|
|
|
#include <nginx.h>
|
2003-02-06 14:21:13 -03:00
|
|
|
|
2002-12-10 15:05:12 -03:00
|
|
|
|
2004-03-16 03:10:12 -04:00
|
|
|
static u_char error_tail[] =
|
2002-12-15 03:25:09 -03:00
|
|
|
"<hr><center>" NGINX_VER "</center>" CRLF
|
|
|
|
"</body>" CRLF
|
|
|
|
"</html>" CRLF
|
|
|
|
;
|
|
|
|
|
2003-02-06 14:21:13 -03:00
|
|
|
|
2005-03-19 08:38:37 -04:00
|
|
|
static u_char ngx_http_msie_stub[] =
|
2003-06-11 11:28:34 -04:00
|
|
|
"<!-- The padding to disable MSIE's friendly error page -->" CRLF
|
|
|
|
"<!-- The padding to disable MSIE's friendly error page -->" CRLF
|
|
|
|
"<!-- The padding to disable MSIE's friendly error page -->" CRLF
|
|
|
|
"<!-- The padding to disable MSIE's friendly error page -->" CRLF
|
|
|
|
"<!-- The padding to disable MSIE's friendly error page -->" CRLF
|
|
|
|
"<!-- The padding to disable MSIE's friendly error page -->" CRLF
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2003-10-12 13:49:16 -03:00
|
|
|
static char error_301_page[] =
|
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>301 Moved Permanently</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>301 Moved Permanently</h1></center>" CRLF
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2003-06-02 11:24:30 -04:00
|
|
|
static char error_302_page[] =
|
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>302 Found</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>302 Found</h1></center>" CRLF
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2002-12-15 03:25:09 -03:00
|
|
|
static char error_400_page[] =
|
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>400 Bad Request</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>400 Bad Request</h1></center>" CRLF
|
|
|
|
;
|
|
|
|
|
2003-02-06 14:21:13 -03:00
|
|
|
|
2005-03-04 11:06:57 -03:00
|
|
|
static char error_401_page[] =
|
|
|
|
"<html>" CRLF
|
2005-03-22 12:02:46 -04:00
|
|
|
"<head><title>401 Authorization Required</title></head>" CRLF
|
2005-03-04 11:06:57 -03:00
|
|
|
"<body bgcolor=\"white\">" CRLF
|
2005-03-22 12:02:46 -04:00
|
|
|
"<center><h1>401 Authorization Required</h1></center>" CRLF
|
2005-03-04 11:06:57 -03:00
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
|
static char error_402_page[] =
|
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>402 Payment Required</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>402 Payment Required</h1></center>" CRLF
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2003-01-10 03:09:20 -03:00
|
|
|
static char error_403_page[] =
|
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>403 Forbidden</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>403 Forbidden</h1></center>" CRLF
|
|
|
|
;
|
|
|
|
|
2003-02-06 14:21:13 -03:00
|
|
|
|
2002-12-15 03:25:09 -03:00
|
|
|
static char error_404_page[] =
|
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>404 Not Found</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>404 Not Found</h1></center>" CRLF
|
|
|
|
;
|
|
|
|
|
2003-02-06 14:21:13 -03:00
|
|
|
|
2003-05-27 08:18:54 -04:00
|
|
|
static char error_405_page[] =
|
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>405 Not Allowed</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>405 Not Allowed</h1></center>" CRLF
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2005-03-04 11:06:57 -03:00
|
|
|
static char error_406_page[] =
|
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>406 Not Acceptable</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>406 Not Acceptable</h1></center>" CRLF
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2003-03-20 12:09:44 -04:00
|
|
|
static char error_408_page[] =
|
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>408 Request Time-out</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>408 Request Time-out</h1></center>" CRLF
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2006-04-19 11:30:56 -04:00
|
|
|
static char error_409_page[] =
|
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>409 Conflict</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>409 Conflict</h1></center>" CRLF
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2005-03-04 11:06:57 -03:00
|
|
|
static char error_410_page[] =
|
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>410 Gone</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>410 Gone</h1></center>" CRLF
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2005-11-26 07:11:11 -03:00
|
|
|
static char error_411_page[] =
|
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>411 Length Required</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>411 Length Required</h1></center>" CRLF
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2003-10-27 18:01:00 -03:00
|
|
|
static char error_413_page[] =
|
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>413 Request Entity Too Large</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>413 Request Entity Too Large</h1></center>" CRLF
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2003-03-11 16:38:13 -04:00
|
|
|
static char error_414_page[] =
|
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>414 Request-URI Too Large</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>414 Request-URI Too Large</h1></center>" CRLF
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2006-04-19 11:30:56 -04:00
|
|
|
static char error_415_page[] =
|
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>415 Unsupported Media Type</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>415 Unsupported Media Type</h1></center>" CRLF
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2003-06-02 11:24:30 -04:00
|
|
|
static char error_416_page[] =
|
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>416 Requested Range Not Satisfiable</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>416 Requested Range Not Satisfiable</h1></center>" CRLF
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2004-07-09 03:12:14 -04:00
|
|
|
static char error_497_page[] =
|
|
|
|
"<html>" CRLF
|
2004-07-18 15:11:20 -04:00
|
|
|
"<head><title>400 The plain HTTP request was sent to HTTPS port</title></head>"
|
|
|
|
CRLF
|
2004-07-09 03:12:14 -04:00
|
|
|
"<body bgcolor=\"white\">" CRLF
|
2004-07-18 15:11:20 -04:00
|
|
|
"<center><h1>400 Bad Request</h1></center>" CRLF
|
|
|
|
"<center>The plain HTTP request was sent to HTTPS port</center>" CRLF
|
2004-07-09 03:12:14 -04:00
|
|
|
;
|
|
|
|
|
|
|
|
|
2003-01-15 04:02:27 -03:00
|
|
|
static char error_500_page[] =
|
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>500 Internal Server Error</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>500 Internal Server Error</h1></center>" CRLF
|
|
|
|
;
|
|
|
|
|
2002-12-15 03:25:09 -03:00
|
|
|
|
2004-01-19 15:09:14 -03:00
|
|
|
static char error_501_page[] =
|
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>501 Method Not Implemented</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
2005-08-23 11:36:54 -04:00
|
|
|
"<center><h1>501 Method Not Implemented</h1></center>" CRLF
|
2004-01-19 15:09:14 -03:00
|
|
|
;
|
|
|
|
|
|
|
|
|
2003-03-20 12:09:44 -04:00
|
|
|
static char error_502_page[] =
|
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>502 Bad Gateway</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>502 Bad Gateway</h1></center>" CRLF
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2003-10-27 18:01:00 -03:00
|
|
|
static char error_503_page[] =
|
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>503 Service Temporarily Unavailable</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>503 Service Temporarily Unavailable</h1></center>" CRLF
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2003-03-20 12:09:44 -04:00
|
|
|
static char error_504_page[] =
|
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>504 Gateway Time-out</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>504 Gateway Time-out</h1></center>" CRLF
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2006-04-19 11:30:56 -04:00
|
|
|
static char error_507_page[] =
|
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>507 Insufficient Storage</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>507 Insufficient Storage</h1></center>" CRLF
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2002-12-15 03:25:09 -03:00
|
|
|
static ngx_str_t error_pages[] = {
|
2005-03-04 11:06:57 -03:00
|
|
|
|
2006-04-14 05:53:38 -04:00
|
|
|
ngx_null_string, /* 201, 204 */
|
2005-05-14 14:42:03 -04:00
|
|
|
|
|
|
|
#define NGX_HTTP_LEVEL_200 1
|
|
|
|
|
2005-03-04 11:06:57 -03:00
|
|
|
/* ngx_null_string, */ /* 300 */
|
2003-10-12 13:49:16 -03:00
|
|
|
ngx_string(error_301_page),
|
2003-06-02 11:24:30 -04:00
|
|
|
ngx_string(error_302_page),
|
2003-03-20 12:09:44 -04:00
|
|
|
ngx_null_string, /* 303 */
|
|
|
|
|
2005-03-04 11:06:57 -03:00
|
|
|
#define NGX_HTTP_LEVEL_300 3
|
|
|
|
|
2003-03-20 12:09:44 -04:00
|
|
|
ngx_string(error_400_page),
|
2005-03-04 11:06:57 -03:00
|
|
|
ngx_string(error_401_page),
|
|
|
|
ngx_string(error_402_page),
|
2003-03-20 12:09:44 -04:00
|
|
|
ngx_string(error_403_page),
|
|
|
|
ngx_string(error_404_page),
|
2003-05-27 08:18:54 -04:00
|
|
|
ngx_string(error_405_page),
|
2005-03-04 11:06:57 -03:00
|
|
|
ngx_string(error_406_page),
|
2003-03-20 12:09:44 -04:00
|
|
|
ngx_null_string, /* 407 */
|
|
|
|
ngx_string(error_408_page),
|
2006-04-19 11:30:56 -04:00
|
|
|
ngx_string(error_409_page),
|
2005-03-04 11:06:57 -03:00
|
|
|
ngx_string(error_410_page),
|
2005-11-26 07:11:11 -03:00
|
|
|
ngx_string(error_411_page),
|
2003-03-20 12:09:44 -04:00
|
|
|
ngx_null_string, /* 412 */
|
2003-10-27 18:01:00 -03:00
|
|
|
ngx_string(error_413_page),
|
2003-03-20 12:09:44 -04:00
|
|
|
ngx_string(error_414_page),
|
2006-04-19 11:30:56 -04:00
|
|
|
ngx_string(error_415_page),
|
2003-06-02 11:24:30 -04:00
|
|
|
ngx_string(error_416_page),
|
2003-03-20 12:09:44 -04:00
|
|
|
|
2005-03-04 11:06:57 -03:00
|
|
|
#define NGX_HTTP_LEVEL_400 17
|
|
|
|
|
2004-07-18 15:11:20 -04:00
|
|
|
ngx_string(error_497_page), /* 497, http to https */
|
2004-07-09 03:12:14 -04:00
|
|
|
ngx_string(error_404_page), /* 498, invalid host name */
|
2005-03-04 11:06:57 -03:00
|
|
|
ngx_null_string, /* 499, client had closed connection */
|
2004-05-14 12:51:47 -04:00
|
|
|
|
2003-03-20 12:09:44 -04:00
|
|
|
ngx_string(error_500_page),
|
2004-01-19 15:09:14 -03:00
|
|
|
ngx_string(error_501_page),
|
2003-03-20 12:09:44 -04:00
|
|
|
ngx_string(error_502_page),
|
2003-10-27 18:01:00 -03:00
|
|
|
ngx_string(error_503_page),
|
2006-04-19 11:30:56 -04:00
|
|
|
ngx_string(error_504_page),
|
|
|
|
ngx_null_string, /* 505 */
|
|
|
|
ngx_null_string, /* 506 */
|
|
|
|
ngx_string(error_507_page)
|
2002-12-15 03:25:09 -03:00
|
|
|
};
|
2002-12-10 15:05:12 -03:00
|
|
|
|
2003-02-06 14:21:13 -03:00
|
|
|
|
2005-02-09 11:31:07 -03:00
|
|
|
ngx_int_t
|
|
|
|
ngx_http_special_response_handler(ngx_http_request_t *r, ngx_int_t error)
|
2002-12-10 15:05:12 -03:00
|
|
|
{
|
2004-03-16 03:10:12 -04:00
|
|
|
ngx_int_t rc;
|
2005-03-19 08:38:37 -04:00
|
|
|
ngx_uint_t i, err, msie_padding;
|
2004-05-28 11:49:23 -04:00
|
|
|
ngx_buf_t *b;
|
2005-03-19 08:38:37 -04:00
|
|
|
ngx_chain_t *out, *cl;
|
2003-11-09 17:03:38 -03:00
|
|
|
ngx_http_err_page_t *err_page;
|
2003-10-24 03:53:41 -03:00
|
|
|
ngx_http_core_loc_conf_t *clcf;
|
2002-12-15 03:25:09 -03:00
|
|
|
|
2005-07-08 10:34:20 -04:00
|
|
|
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
|
|
"http special response: %d, \"%V\"", error, &r->uri);
|
|
|
|
|
2003-10-27 13:16:17 -03:00
|
|
|
rc = ngx_http_discard_body(r);
|
|
|
|
|
2004-03-23 02:01:52 -04:00
|
|
|
if (rc == NGX_HTTP_INTERNAL_SERVER_ERROR) {
|
|
|
|
error = NGX_HTTP_INTERNAL_SERVER_ERROR;
|
2003-10-27 13:16:17 -03:00
|
|
|
}
|
|
|
|
|
2002-12-15 03:25:09 -03:00
|
|
|
r->headers_out.status = error;
|
|
|
|
|
2003-03-12 13:32:22 -04:00
|
|
|
if (r->keepalive != 0) {
|
|
|
|
switch (error) {
|
|
|
|
case NGX_HTTP_BAD_REQUEST:
|
2003-10-27 18:01:00 -03:00
|
|
|
case NGX_HTTP_REQUEST_ENTITY_TOO_LARGE:
|
2003-03-12 13:32:22 -04:00
|
|
|
case NGX_HTTP_REQUEST_URI_TOO_LARGE:
|
2004-07-09 03:12:14 -04:00
|
|
|
case NGX_HTTP_TO_HTTPS:
|
2003-03-12 13:32:22 -04:00
|
|
|
case NGX_HTTP_INTERNAL_SERVER_ERROR:
|
|
|
|
r->keepalive = 0;
|
|
|
|
}
|
|
|
|
}
|
2002-12-15 03:25:09 -03:00
|
|
|
|
2003-05-14 13:13:13 -04:00
|
|
|
if (r->lingering_close == 1) {
|
|
|
|
switch (error) {
|
|
|
|
case NGX_HTTP_BAD_REQUEST:
|
2004-07-09 03:12:14 -04:00
|
|
|
case NGX_HTTP_TO_HTTPS:
|
2003-05-14 13:13:13 -04:00
|
|
|
r->lingering_close = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-09 17:03:38 -03:00
|
|
|
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
|
|
|
|
|
2003-11-11 15:13:43 -03:00
|
|
|
if (r->err_ctx == NULL && clcf->error_pages) {
|
2004-12-21 09:30:30 -03:00
|
|
|
|
2003-11-09 17:03:38 -03:00
|
|
|
err_page = clcf->error_pages->elts;
|
2004-12-21 09:30:30 -03:00
|
|
|
|
2003-11-09 17:03:38 -03:00
|
|
|
for (i = 0; i < clcf->error_pages->nelts; i++) {
|
2004-12-21 09:30:30 -03:00
|
|
|
|
2004-04-25 16:13:21 -04:00
|
|
|
if (err_page[i].status == error) {
|
2005-10-05 10:46:21 -04:00
|
|
|
r->err_status = err_page[i].overwrite;
|
|
|
|
r->err_ctx = r->ctx;
|
2004-12-21 09:30:30 -03:00
|
|
|
|
2005-10-05 10:46:21 -04:00
|
|
|
r->method = NGX_HTTP_GET;
|
|
|
|
|
|
|
|
if (err_page[i].uri.data[0] == '/') {
|
|
|
|
return ngx_http_internal_redirect(r, &err_page[i].uri,
|
|
|
|
NULL);
|
2004-04-21 14:54:33 -04:00
|
|
|
}
|
2004-12-21 09:30:30 -03:00
|
|
|
|
2005-10-05 10:46:21 -04:00
|
|
|
r->headers_out.location =
|
|
|
|
ngx_list_push(&r->headers_out.headers);
|
2004-12-21 09:30:30 -03:00
|
|
|
|
2005-10-05 10:46:21 -04:00
|
|
|
if (r->headers_out.location) {
|
|
|
|
r->err_status = NGX_HTTP_MOVED_TEMPORARILY;
|
|
|
|
error = NGX_HTTP_MOVED_TEMPORARILY;
|
|
|
|
|
|
|
|
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;
|
2005-09-06 12:09:32 -04:00
|
|
|
|
2005-10-05 10:46:21 -04:00
|
|
|
} else {
|
|
|
|
error = NGX_HTTP_INTERNAL_SERVER_ERROR;
|
|
|
|
}
|
2003-11-09 17:03:38 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-14 05:53:38 -04:00
|
|
|
if (error == NGX_HTTP_CREATED) {
|
|
|
|
/* 201 */
|
|
|
|
err = 0;
|
2006-04-19 11:30:56 -04:00
|
|
|
r->header_only = 1;
|
2006-04-14 05:53:38 -04:00
|
|
|
|
|
|
|
} else if (error == NGX_HTTP_NO_CONTENT) {
|
2005-05-14 14:42:03 -04:00
|
|
|
/* 204 */
|
|
|
|
err = 0;
|
|
|
|
|
|
|
|
} else if (error < NGX_HTTP_BAD_REQUEST) {
|
2003-11-09 17:03:38 -03:00
|
|
|
/* 3XX */
|
2005-05-16 09:53:20 -04:00
|
|
|
err = error - NGX_HTTP_MOVED_PERMANENTLY + NGX_HTTP_LEVEL_200;
|
2003-11-09 17:03:38 -03:00
|
|
|
|
2005-12-07 11:51:31 -03:00
|
|
|
} else if (error < NGX_HTTP_OWN_CODES) {
|
2003-11-09 17:03:38 -03:00
|
|
|
/* 4XX */
|
2005-05-14 14:42:03 -04:00
|
|
|
err = error - NGX_HTTP_BAD_REQUEST + NGX_HTTP_LEVEL_200
|
|
|
|
+ NGX_HTTP_LEVEL_300;
|
2003-11-09 17:03:38 -03:00
|
|
|
|
|
|
|
} else {
|
2004-05-14 12:51:47 -04:00
|
|
|
/* 49X, 5XX */
|
2005-12-07 11:51:31 -03:00
|
|
|
err = error - NGX_HTTP_OWN_CODES + NGX_HTTP_LEVEL_200
|
2005-05-14 14:42:03 -04:00
|
|
|
+ NGX_HTTP_LEVEL_300
|
2005-03-04 11:06:57 -03:00
|
|
|
+ NGX_HTTP_LEVEL_400;
|
2004-05-14 12:51:47 -04:00
|
|
|
switch (error) {
|
2004-07-09 03:12:14 -04:00
|
|
|
case NGX_HTTP_TO_HTTPS:
|
|
|
|
r->headers_out.status = NGX_HTTP_BAD_REQUEST;
|
|
|
|
error = NGX_HTTP_BAD_REQUEST;
|
|
|
|
break;
|
2004-05-14 12:51:47 -04:00
|
|
|
}
|
2003-11-09 17:03:38 -03:00
|
|
|
}
|
|
|
|
|
2004-06-16 11:32:11 -04:00
|
|
|
msie_padding = 0;
|
|
|
|
|
2003-06-02 11:24:30 -04:00
|
|
|
if (error_pages[err].len) {
|
2003-10-21 13:49:56 -03:00
|
|
|
r->headers_out.content_length_n = error_pages[err].len
|
2004-05-04 13:56:58 -04:00
|
|
|
+ sizeof(error_tail) - 1;
|
|
|
|
|
|
|
|
if (clcf->msie_padding
|
2004-06-16 11:32:11 -04:00
|
|
|
&& r->headers_in.msie
|
2004-05-04 13:56:58 -04:00
|
|
|
&& r->http_version >= NGX_HTTP_VERSION_10
|
|
|
|
&& error >= NGX_HTTP_BAD_REQUEST
|
|
|
|
&& error != NGX_HTTP_REQUEST_URI_TOO_LARGE)
|
|
|
|
{
|
2005-03-19 08:38:37 -04:00
|
|
|
r->headers_out.content_length_n += sizeof(ngx_http_msie_stub) - 1;
|
2004-06-16 11:32:11 -04:00
|
|
|
msie_padding = 1;
|
2004-05-04 13:56:58 -04:00
|
|
|
}
|
2003-06-02 11:24:30 -04:00
|
|
|
|
nginx-0.1.29-RELEASE import
*) Feature: the ngx_http_ssi_module supports "include virtual" command.
*) Feature: the ngx_http_ssi_module supports the condition command like
'if expr="$NAME"' and "else" and "endif" commands. Only one nested
level is supported.
*) Feature: the ngx_http_ssi_module supports the DATE_LOCAL and
DATE_GMT variables and "config timefmt" command.
*) Feature: the "ssi_ignore_recycled_buffers" directive.
*) Bugfix: the "echo" command did not show the default value for the
empty QUERY_STRING variable.
*) Change: the ngx_http_proxy_module was rewritten.
*) Feature: the "proxy_redirect", "proxy_pass_request_headers",
"proxy_pass_request_body", and "proxy_method" directives.
*) Feature: the "proxy_set_header" directive. The "proxy_x_var" was
canceled and must be replaced with the proxy_set_header directive.
*) Change: the "proxy_preserve_host" is canceled and must be replaced
with the "proxy_set_header Host $host" and the "proxy_redirect off"
directives, the "proxy_set_header Host $host:$proxy_port" directive
and the appropriate proxy_redirect directives.
*) Change: the "proxy_set_x_real_ip" is canceled and must be replaced
with the "proxy_set_header X-Real-IP $remote_addr" directive.
*) Change: the "proxy_add_x_forwarded_for" is canceled and must be
replaced with
the "proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for"
directive.
*) Change: the "proxy_set_x_url" is canceled and must be replaced with
the "proxy_set_header X-URL http://$host:$server_port$request_uri"
directive.
*) Feature: the "fastcgi_param" directive.
*) Change: the "fastcgi_root", "fastcgi_set_var" and "fastcgi_params"
directive are canceled and must be replaced with the fastcgi_param
directives.
*) Feature: the "index" directive can use the variables.
*) Feature: the "index" directive can be used at http and server levels.
*) Change: the last index only in the "index" directive can be absolute.
*) Feature: the "rewrite" directive can use the variables.
*) Feature: the "internal" directive.
*) Feature: the CONTENT_LENGTH, CONTENT_TYPE, REMOTE_PORT, SERVER_ADDR,
SERVER_PORT, SERVER_PROTOCOL, DOCUMENT_ROOT, SERVER_NAME,
REQUEST_METHOD, REQUEST_URI, and REMOTE_USER variables.
*) Change: nginx now passes the invalid lines in a client request
headers or a backend response header.
*) Bugfix: if the backend did not transfer response for a long time and
the "send_timeout" was less than "proxy_read_timeout", then nginx
returned the 408 response.
*) Bugfix: the segmentation fault was occurred if the backend sent an
invalid line in response header; the bug had appeared in 0.1.26.
*) Bugfix: the segmentation fault may occurred in FastCGI fault
tolerance configuration.
*) Bugfix: the "expires" directive did not remove the previous
"Expires" and "Cache-Control" headers.
*) Bugfix: nginx did not take into account trailing dot in "Host"
header line.
*) Bugfix: the ngx_http_auth_module did not work under Linux.
*) Bugfix: the rewrite directive worked incorrectly, if the arguments
were in a request.
*) Bugfix: nginx could not be built on MacOS X.
2005-05-12 10:58:06 -04:00
|
|
|
r->headers_out.content_type.len = sizeof("text/html") - 1;
|
|
|
|
r->headers_out.content_type.data = (u_char *) "text/html";
|
2003-06-02 11:24:30 -04:00
|
|
|
|
|
|
|
} else {
|
2003-10-21 13:49:56 -03:00
|
|
|
r->headers_out.content_length_n = -1;
|
2003-10-29 14:39:05 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (r->headers_out.content_length) {
|
nginx-0.1.29-RELEASE import
*) Feature: the ngx_http_ssi_module supports "include virtual" command.
*) Feature: the ngx_http_ssi_module supports the condition command like
'if expr="$NAME"' and "else" and "endif" commands. Only one nested
level is supported.
*) Feature: the ngx_http_ssi_module supports the DATE_LOCAL and
DATE_GMT variables and "config timefmt" command.
*) Feature: the "ssi_ignore_recycled_buffers" directive.
*) Bugfix: the "echo" command did not show the default value for the
empty QUERY_STRING variable.
*) Change: the ngx_http_proxy_module was rewritten.
*) Feature: the "proxy_redirect", "proxy_pass_request_headers",
"proxy_pass_request_body", and "proxy_method" directives.
*) Feature: the "proxy_set_header" directive. The "proxy_x_var" was
canceled and must be replaced with the proxy_set_header directive.
*) Change: the "proxy_preserve_host" is canceled and must be replaced
with the "proxy_set_header Host $host" and the "proxy_redirect off"
directives, the "proxy_set_header Host $host:$proxy_port" directive
and the appropriate proxy_redirect directives.
*) Change: the "proxy_set_x_real_ip" is canceled and must be replaced
with the "proxy_set_header X-Real-IP $remote_addr" directive.
*) Change: the "proxy_add_x_forwarded_for" is canceled and must be
replaced with
the "proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for"
directive.
*) Change: the "proxy_set_x_url" is canceled and must be replaced with
the "proxy_set_header X-URL http://$host:$server_port$request_uri"
directive.
*) Feature: the "fastcgi_param" directive.
*) Change: the "fastcgi_root", "fastcgi_set_var" and "fastcgi_params"
directive are canceled and must be replaced with the fastcgi_param
directives.
*) Feature: the "index" directive can use the variables.
*) Feature: the "index" directive can be used at http and server levels.
*) Change: the last index only in the "index" directive can be absolute.
*) Feature: the "rewrite" directive can use the variables.
*) Feature: the "internal" directive.
*) Feature: the CONTENT_LENGTH, CONTENT_TYPE, REMOTE_PORT, SERVER_ADDR,
SERVER_PORT, SERVER_PROTOCOL, DOCUMENT_ROOT, SERVER_NAME,
REQUEST_METHOD, REQUEST_URI, and REMOTE_USER variables.
*) Change: nginx now passes the invalid lines in a client request
headers or a backend response header.
*) Bugfix: if the backend did not transfer response for a long time and
the "send_timeout" was less than "proxy_read_timeout", then nginx
returned the 408 response.
*) Bugfix: the segmentation fault was occurred if the backend sent an
invalid line in response header; the bug had appeared in 0.1.26.
*) Bugfix: the segmentation fault may occurred in FastCGI fault
tolerance configuration.
*) Bugfix: the "expires" directive did not remove the previous
"Expires" and "Cache-Control" headers.
*) Bugfix: nginx did not take into account trailing dot in "Host"
header line.
*) Bugfix: the ngx_http_auth_module did not work under Linux.
*) Bugfix: the rewrite directive worked incorrectly, if the arguments
were in a request.
*) Bugfix: nginx could not be built on MacOS X.
2005-05-12 10:58:06 -04:00
|
|
|
r->headers_out.content_length->hash = 0;
|
2003-10-21 13:49:56 -03:00
|
|
|
r->headers_out.content_length = NULL;
|
2003-03-12 13:32:22 -04:00
|
|
|
}
|
2002-12-15 03:25:09 -03:00
|
|
|
|
2005-11-15 10:30:52 -03:00
|
|
|
ngx_http_clear_accept_ranges(r);
|
|
|
|
ngx_http_clear_last_modified(r);
|
|
|
|
|
2003-06-11 11:28:34 -04:00
|
|
|
rc = ngx_http_send_header(r);
|
2003-10-09 03:00:45 -04:00
|
|
|
|
2003-10-10 11:10:50 -04:00
|
|
|
if (rc == NGX_ERROR || r->header_only) {
|
|
|
|
return rc;
|
2003-06-11 11:28:34 -04:00
|
|
|
}
|
|
|
|
|
2003-02-06 14:21:13 -03:00
|
|
|
if (error_pages[err].len == 0) {
|
2002-12-15 03:25:09 -03:00
|
|
|
return NGX_OK;
|
2003-02-06 14:21:13 -03:00
|
|
|
}
|
2002-12-15 03:25:09 -03:00
|
|
|
|
|
|
|
|
2005-03-19 08:38:37 -04:00
|
|
|
b = ngx_calloc_buf(r->pool);
|
|
|
|
if (b == NULL) {
|
2003-10-29 05:30:44 -03:00
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
2005-03-19 08:38:37 -04:00
|
|
|
|
2004-05-28 11:49:23 -04:00
|
|
|
b->memory = 1;
|
|
|
|
b->pos = error_pages[err].data;
|
|
|
|
b->last = error_pages[err].data + error_pages[err].len;
|
2002-12-15 03:25:09 -03:00
|
|
|
|
2005-03-19 08:38:37 -04:00
|
|
|
cl = ngx_alloc_chain_link(r->pool);
|
|
|
|
if (cl == NULL) {
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
cl->buf = b;
|
|
|
|
out = cl;
|
2002-12-10 15:05:12 -03:00
|
|
|
|
2003-06-11 11:28:34 -04:00
|
|
|
|
2005-03-19 08:38:37 -04:00
|
|
|
b = ngx_calloc_buf(r->pool);
|
|
|
|
if (b == NULL) {
|
2003-10-29 05:30:44 -03:00
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
2005-03-19 08:38:37 -04:00
|
|
|
|
2004-05-28 11:49:23 -04:00
|
|
|
b->memory = 1;
|
|
|
|
b->pos = error_tail;
|
|
|
|
b->last = error_tail + sizeof(error_tail) - 1;
|
2003-06-11 11:28:34 -04:00
|
|
|
|
2005-03-19 08:38:37 -04:00
|
|
|
cl->next = ngx_alloc_chain_link(r->pool);
|
|
|
|
if (cl->next == NULL) {
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
cl = cl->next;
|
|
|
|
cl->buf = b;
|
2003-10-21 13:49:56 -03:00
|
|
|
|
2004-06-16 11:32:11 -04:00
|
|
|
if (msie_padding) {
|
2005-03-19 08:38:37 -04:00
|
|
|
b = ngx_calloc_buf(r->pool);
|
|
|
|
if (b == NULL) {
|
2003-10-29 05:30:44 -03:00
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
2005-03-19 08:38:37 -04:00
|
|
|
|
2004-05-28 11:49:23 -04:00
|
|
|
b->memory = 1;
|
2005-03-19 08:38:37 -04:00
|
|
|
b->pos = ngx_http_msie_stub;
|
|
|
|
b->last = ngx_http_msie_stub + sizeof(ngx_http_msie_stub) - 1;
|
|
|
|
|
|
|
|
cl->next = ngx_alloc_chain_link(r->pool);
|
|
|
|
if (cl->next == NULL) {
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
2003-10-21 13:49:56 -03:00
|
|
|
|
2005-03-19 08:38:37 -04:00
|
|
|
cl = cl->next;
|
|
|
|
cl->buf = b;
|
2003-06-11 11:28:34 -04:00
|
|
|
}
|
|
|
|
|
2006-01-11 12:26:57 -03:00
|
|
|
if (r == r->main) {
|
nginx-0.1.29-RELEASE import
*) Feature: the ngx_http_ssi_module supports "include virtual" command.
*) Feature: the ngx_http_ssi_module supports the condition command like
'if expr="$NAME"' and "else" and "endif" commands. Only one nested
level is supported.
*) Feature: the ngx_http_ssi_module supports the DATE_LOCAL and
DATE_GMT variables and "config timefmt" command.
*) Feature: the "ssi_ignore_recycled_buffers" directive.
*) Bugfix: the "echo" command did not show the default value for the
empty QUERY_STRING variable.
*) Change: the ngx_http_proxy_module was rewritten.
*) Feature: the "proxy_redirect", "proxy_pass_request_headers",
"proxy_pass_request_body", and "proxy_method" directives.
*) Feature: the "proxy_set_header" directive. The "proxy_x_var" was
canceled and must be replaced with the proxy_set_header directive.
*) Change: the "proxy_preserve_host" is canceled and must be replaced
with the "proxy_set_header Host $host" and the "proxy_redirect off"
directives, the "proxy_set_header Host $host:$proxy_port" directive
and the appropriate proxy_redirect directives.
*) Change: the "proxy_set_x_real_ip" is canceled and must be replaced
with the "proxy_set_header X-Real-IP $remote_addr" directive.
*) Change: the "proxy_add_x_forwarded_for" is canceled and must be
replaced with
the "proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for"
directive.
*) Change: the "proxy_set_x_url" is canceled and must be replaced with
the "proxy_set_header X-URL http://$host:$server_port$request_uri"
directive.
*) Feature: the "fastcgi_param" directive.
*) Change: the "fastcgi_root", "fastcgi_set_var" and "fastcgi_params"
directive are canceled and must be replaced with the fastcgi_param
directives.
*) Feature: the "index" directive can use the variables.
*) Feature: the "index" directive can be used at http and server levels.
*) Change: the last index only in the "index" directive can be absolute.
*) Feature: the "rewrite" directive can use the variables.
*) Feature: the "internal" directive.
*) Feature: the CONTENT_LENGTH, CONTENT_TYPE, REMOTE_PORT, SERVER_ADDR,
SERVER_PORT, SERVER_PROTOCOL, DOCUMENT_ROOT, SERVER_NAME,
REQUEST_METHOD, REQUEST_URI, and REMOTE_USER variables.
*) Change: nginx now passes the invalid lines in a client request
headers or a backend response header.
*) Bugfix: if the backend did not transfer response for a long time and
the "send_timeout" was less than "proxy_read_timeout", then nginx
returned the 408 response.
*) Bugfix: the segmentation fault was occurred if the backend sent an
invalid line in response header; the bug had appeared in 0.1.26.
*) Bugfix: the segmentation fault may occurred in FastCGI fault
tolerance configuration.
*) Bugfix: the "expires" directive did not remove the previous
"Expires" and "Cache-Control" headers.
*) Bugfix: nginx did not take into account trailing dot in "Host"
header line.
*) Bugfix: the ngx_http_auth_module did not work under Linux.
*) Bugfix: the rewrite directive worked incorrectly, if the arguments
were in a request.
*) Bugfix: nginx could not be built on MacOS X.
2005-05-12 10:58:06 -04:00
|
|
|
b->last_buf = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
b->last_in_chain = 1;
|
2003-06-11 11:28:34 -04:00
|
|
|
|
2005-03-19 08:38:37 -04:00
|
|
|
cl->next = NULL;
|
|
|
|
|
2003-10-21 13:49:56 -03:00
|
|
|
return ngx_http_output_filter(r, out);
|
2002-12-10 15:05:12 -03:00
|
|
|
}
|