2002-12-11 02:05:12 +08:00
|
|
|
|
2004-09-28 16:34:51 +08:00
|
|
|
/*
|
2004-09-30 00:00:49 +08:00
|
|
|
* Copyright (C) Igor Sysoev
|
2004-09-28 16:34:51 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2002-12-11 02:05:12 +08:00
|
|
|
#include <ngx_config.h>
|
|
|
|
#include <ngx_core.h>
|
|
|
|
#include <ngx_http.h>
|
2003-06-02 23:24:30 +08:00
|
|
|
#include <nginx.h>
|
2003-02-07 01:21:13 +08:00
|
|
|
|
2002-12-11 02:05:12 +08:00
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
static ngx_int_t ngx_http_send_error_page(ngx_http_request_t *r,
|
|
|
|
ngx_http_err_page_t *err_page);
|
|
|
|
static ngx_int_t ngx_http_send_special_response(ngx_http_request_t *r,
|
|
|
|
ngx_http_core_loc_conf_t *clcf, ngx_uint_t err);
|
|
|
|
static ngx_int_t ngx_http_send_refresh(ngx_http_request_t *r);
|
|
|
|
|
|
|
|
|
|
|
|
static u_char ngx_http_error_full_tail[] =
|
2002-12-15 14:25:09 +08:00
|
|
|
"<hr><center>" NGINX_VER "</center>" CRLF
|
|
|
|
"</body>" CRLF
|
|
|
|
"</html>" CRLF
|
|
|
|
;
|
|
|
|
|
2003-02-07 01:21:13 +08:00
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
static u_char ngx_http_error_tail[] =
|
2007-10-22 18:17:34 +08:00
|
|
|
"<hr><center>nginx</center>" CRLF
|
|
|
|
"</body>" CRLF
|
|
|
|
"</html>" CRLF
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2005-03-19 20:38:37 +08:00
|
|
|
static u_char ngx_http_msie_stub[] =
|
2003-06-11 23:28:34 +08: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
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2006-08-29 00:57:48 +08:00
|
|
|
static u_char ngx_http_msie_refresh_head[] =
|
|
|
|
"<html><head><meta http-equiv=\"Refresh\" content=\"0; URL=";
|
|
|
|
|
|
|
|
|
|
|
|
static u_char ngx_http_msie_refresh_tail[] =
|
|
|
|
"\"></head><body></body></html>" CRLF;
|
|
|
|
|
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
static char ngx_http_error_301_page[] =
|
2003-10-13 00:49:16 +08:00
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>301 Moved Permanently</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>301 Moved Permanently</h1></center>" CRLF
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
static char ngx_http_error_302_page[] =
|
2003-06-02 23:24:30 +08:00
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>302 Found</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>302 Found</h1></center>" CRLF
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
static char ngx_http_error_400_page[] =
|
2002-12-15 14:25:09 +08:00
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>400 Bad Request</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>400 Bad Request</h1></center>" CRLF
|
|
|
|
;
|
|
|
|
|
2003-02-07 01:21:13 +08:00
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
static char ngx_http_error_401_page[] =
|
2005-03-04 22:06:57 +08:00
|
|
|
"<html>" CRLF
|
2005-03-23 00:02:46 +08:00
|
|
|
"<head><title>401 Authorization Required</title></head>" CRLF
|
2005-03-04 22:06:57 +08:00
|
|
|
"<body bgcolor=\"white\">" CRLF
|
2005-03-23 00:02:46 +08:00
|
|
|
"<center><h1>401 Authorization Required</h1></center>" CRLF
|
2005-03-04 22:06:57 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
static char ngx_http_error_402_page[] =
|
2005-03-04 22:06:57 +08:00
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>402 Payment Required</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>402 Payment Required</h1></center>" CRLF
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
static char ngx_http_error_403_page[] =
|
2003-01-10 14:09:20 +08:00
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>403 Forbidden</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>403 Forbidden</h1></center>" CRLF
|
|
|
|
;
|
|
|
|
|
2003-02-07 01:21:13 +08:00
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
static char ngx_http_error_404_page[] =
|
2002-12-15 14:25:09 +08:00
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>404 Not Found</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>404 Not Found</h1></center>" CRLF
|
|
|
|
;
|
|
|
|
|
2003-02-07 01:21:13 +08:00
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
static char ngx_http_error_405_page[] =
|
2003-05-27 20:18:54 +08:00
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>405 Not Allowed</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>405 Not Allowed</h1></center>" CRLF
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
static char ngx_http_error_406_page[] =
|
2005-03-04 22:06:57 +08:00
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>406 Not Acceptable</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>406 Not Acceptable</h1></center>" CRLF
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
static char ngx_http_error_408_page[] =
|
2003-03-21 00:09:44 +08:00
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>408 Request Time-out</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>408 Request Time-out</h1></center>" CRLF
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
static char ngx_http_error_409_page[] =
|
2006-04-19 23:30:56 +08:00
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>409 Conflict</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>409 Conflict</h1></center>" CRLF
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
static char ngx_http_error_410_page[] =
|
2005-03-04 22:06:57 +08:00
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>410 Gone</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>410 Gone</h1></center>" CRLF
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
static char ngx_http_error_411_page[] =
|
2005-11-26 18:11:11 +08:00
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>411 Length Required</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>411 Length Required</h1></center>" CRLF
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
static char ngx_http_error_412_page[] =
|
2007-01-19 04:51:51 +08:00
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>412 Precondition Failed</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>412 Precondition Failed</h1></center>" CRLF
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
static char ngx_http_error_413_page[] =
|
2003-10-28 05:01:00 +08:00
|
|
|
"<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
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
static char ngx_http_error_414_page[] =
|
2003-03-12 04:38:13 +08:00
|
|
|
"<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
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
static char ngx_http_error_415_page[] =
|
2006-04-19 23:30:56 +08:00
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>415 Unsupported Media Type</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>415 Unsupported Media Type</h1></center>" CRLF
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
static char ngx_http_error_416_page[] =
|
2003-06-02 23:24:30 +08:00
|
|
|
"<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
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
static char ngx_http_error_495_page[] =
|
2006-05-07 00:28:56 +08:00
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>400 The SSL certificate error</title></head>"
|
|
|
|
CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>400 Bad Request</h1></center>" CRLF
|
|
|
|
"<center>The SSL certificate error</center>" CRLF
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
static char ngx_http_error_496_page[] =
|
2006-05-07 00:28:56 +08:00
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>400 No required SSL certificate was sent</title></head>"
|
|
|
|
CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>400 Bad Request</h1></center>" CRLF
|
|
|
|
"<center>No required SSL certificate was sent</center>" CRLF
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
static char ngx_http_error_497_page[] =
|
2004-07-09 15:12:14 +08:00
|
|
|
"<html>" CRLF
|
2004-07-19 03:11:20 +08:00
|
|
|
"<head><title>400 The plain HTTP request was sent to HTTPS port</title></head>"
|
|
|
|
CRLF
|
2004-07-09 15:12:14 +08:00
|
|
|
"<body bgcolor=\"white\">" CRLF
|
2004-07-19 03:11:20 +08:00
|
|
|
"<center><h1>400 Bad Request</h1></center>" CRLF
|
|
|
|
"<center>The plain HTTP request was sent to HTTPS port</center>" CRLF
|
2004-07-09 15:12:14 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
static char ngx_http_error_500_page[] =
|
2003-01-15 15:02:27 +08:00
|
|
|
"<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 14:25:09 +08:00
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
static char ngx_http_error_501_page[] =
|
2004-01-20 02:09:14 +08:00
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>501 Method Not Implemented</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
2005-08-23 23:36:54 +08:00
|
|
|
"<center><h1>501 Method Not Implemented</h1></center>" CRLF
|
2004-01-20 02:09:14 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
static char ngx_http_error_502_page[] =
|
2003-03-21 00:09:44 +08:00
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>502 Bad Gateway</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>502 Bad Gateway</h1></center>" CRLF
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
static char ngx_http_error_503_page[] =
|
2003-10-28 05:01:00 +08:00
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>503 Service Temporarily Unavailable</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>503 Service Temporarily Unavailable</h1></center>" CRLF
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
static char ngx_http_error_504_page[] =
|
2003-03-21 00:09:44 +08:00
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>504 Gateway Time-out</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>504 Gateway Time-out</h1></center>" CRLF
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
static char ngx_http_error_507_page[] =
|
2006-04-19 23:30:56 +08:00
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>507 Insufficient Storage</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<center><h1>507 Insufficient Storage</h1></center>" CRLF
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
static ngx_str_t ngx_http_error_pages[] = {
|
2005-03-04 22:06:57 +08:00
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
ngx_null_string, /* 201, 204 */
|
2005-05-15 02:42:03 +08:00
|
|
|
|
2009-04-11 19:05:15 +08:00
|
|
|
#define NGX_HTTP_LAST_LEVEL_200 202
|
|
|
|
#define NGX_HTTP_LEVEL_200 (NGX_HTTP_LAST_LEVEL_200 - 201)
|
2005-05-15 02:42:03 +08:00
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
/* ngx_null_string, */ /* 300 */
|
|
|
|
ngx_string(ngx_http_error_301_page),
|
|
|
|
ngx_string(ngx_http_error_302_page),
|
|
|
|
ngx_null_string, /* 303 */
|
2003-03-21 00:09:44 +08:00
|
|
|
|
2009-04-11 19:05:15 +08:00
|
|
|
#define NGX_HTTP_LAST_LEVEL_300 304
|
|
|
|
#define NGX_HTTP_LEVEL_300 (NGX_HTTP_LAST_LEVEL_300 - 301)
|
2005-03-04 22:06:57 +08:00
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
ngx_string(ngx_http_error_400_page),
|
|
|
|
ngx_string(ngx_http_error_401_page),
|
|
|
|
ngx_string(ngx_http_error_402_page),
|
|
|
|
ngx_string(ngx_http_error_403_page),
|
|
|
|
ngx_string(ngx_http_error_404_page),
|
|
|
|
ngx_string(ngx_http_error_405_page),
|
|
|
|
ngx_string(ngx_http_error_406_page),
|
|
|
|
ngx_null_string, /* 407 */
|
|
|
|
ngx_string(ngx_http_error_408_page),
|
|
|
|
ngx_string(ngx_http_error_409_page),
|
|
|
|
ngx_string(ngx_http_error_410_page),
|
|
|
|
ngx_string(ngx_http_error_411_page),
|
|
|
|
ngx_string(ngx_http_error_412_page),
|
|
|
|
ngx_string(ngx_http_error_413_page),
|
|
|
|
ngx_string(ngx_http_error_414_page),
|
|
|
|
ngx_string(ngx_http_error_415_page),
|
|
|
|
ngx_string(ngx_http_error_416_page),
|
2003-03-21 00:09:44 +08:00
|
|
|
|
2009-04-11 19:05:15 +08:00
|
|
|
#define NGX_HTTP_LAST_LEVEL_400 417
|
|
|
|
#define NGX_HTTP_LEVEL_400 (NGX_HTTP_LAST_LEVEL_400 - 400)
|
2005-03-04 22:06:57 +08:00
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
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 */
|
2007-12-01 06:06:48 +08:00
|
|
|
ngx_string(ngx_http_error_404_page), /* 498, canceled */
|
2007-10-27 00:17:17 +08:00
|
|
|
ngx_null_string, /* 499, client has closed connection */
|
|
|
|
|
|
|
|
ngx_string(ngx_http_error_500_page),
|
|
|
|
ngx_string(ngx_http_error_501_page),
|
|
|
|
ngx_string(ngx_http_error_502_page),
|
|
|
|
ngx_string(ngx_http_error_503_page),
|
|
|
|
ngx_string(ngx_http_error_504_page),
|
|
|
|
ngx_null_string, /* 505 */
|
|
|
|
ngx_null_string, /* 506 */
|
|
|
|
ngx_string(ngx_http_error_507_page)
|
2009-04-11 19:05:15 +08:00
|
|
|
|
|
|
|
#define NGX_HTTP_LAST_LEVEL_500 508
|
|
|
|
|
2002-12-15 14:25:09 +08:00
|
|
|
};
|
2002-12-11 02:05:12 +08:00
|
|
|
|
2003-02-07 01:21:13 +08:00
|
|
|
|
2006-09-26 04:04:54 +08:00
|
|
|
static ngx_str_t ngx_http_get_name = { 3, (u_char *) "GET " };
|
2006-09-26 01:49:49 +08:00
|
|
|
|
|
|
|
|
2005-02-09 22:31:07 +08:00
|
|
|
ngx_int_t
|
|
|
|
ngx_http_special_response_handler(ngx_http_request_t *r, ngx_int_t error)
|
2002-12-11 02:05:12 +08:00
|
|
|
{
|
2007-10-27 00:17:17 +08:00
|
|
|
ngx_uint_t i, err;
|
2003-11-10 04:03:38 +08:00
|
|
|
ngx_http_err_page_t *err_page;
|
2003-10-24 14:53:41 +08:00
|
|
|
ngx_http_core_loc_conf_t *clcf;
|
2002-12-15 14:25:09 +08:00
|
|
|
|
2008-05-28 20:26:20 +08:00
|
|
|
ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
2008-05-27 02:49:36 +08:00
|
|
|
"http special response: %d, \"%V?%V\"",
|
|
|
|
error, &r->uri, &r->args);
|
2005-07-08 22:34:20 +08:00
|
|
|
|
2006-08-18 22:17:54 +08:00
|
|
|
r->err_status = error;
|
2002-12-15 14:25:09 +08:00
|
|
|
|
2008-05-22 01:39:51 +08:00
|
|
|
if (r->keepalive) {
|
2003-03-13 01:32:22 +08:00
|
|
|
switch (error) {
|
|
|
|
case NGX_HTTP_BAD_REQUEST:
|
2003-10-28 05:01:00 +08:00
|
|
|
case NGX_HTTP_REQUEST_ENTITY_TOO_LARGE:
|
2003-03-13 01:32:22 +08:00
|
|
|
case NGX_HTTP_REQUEST_URI_TOO_LARGE:
|
2004-07-09 15:12:14 +08:00
|
|
|
case NGX_HTTP_TO_HTTPS:
|
2006-05-07 00:28:56 +08:00
|
|
|
case NGX_HTTPS_CERT_ERROR:
|
|
|
|
case NGX_HTTPS_NO_CERT:
|
2003-03-13 01:32:22 +08:00
|
|
|
case NGX_HTTP_INTERNAL_SERVER_ERROR:
|
|
|
|
r->keepalive = 0;
|
|
|
|
}
|
|
|
|
}
|
2002-12-15 14:25:09 +08:00
|
|
|
|
2003-05-15 01:13:13 +08:00
|
|
|
if (r->lingering_close == 1) {
|
|
|
|
switch (error) {
|
|
|
|
case NGX_HTTP_BAD_REQUEST:
|
2004-07-09 15:12:14 +08:00
|
|
|
case NGX_HTTP_TO_HTTPS:
|
2006-05-07 00:28:56 +08:00
|
|
|
case NGX_HTTPS_CERT_ERROR:
|
|
|
|
case NGX_HTTPS_NO_CERT:
|
2003-05-15 01:13:13 +08:00
|
|
|
r->lingering_close = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-08-16 21:09:33 +08:00
|
|
|
r->headers_out.content_type.len = 0;
|
|
|
|
|
2003-11-10 04:03:38 +08:00
|
|
|
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
|
|
|
|
|
2008-08-13 17:00:13 +08:00
|
|
|
if (!r->error_page && clcf->error_pages && r->uri_changes != 0) {
|
2006-08-29 00:57:48 +08:00
|
|
|
|
|
|
|
if (clcf->recursive_error_pages == 0) {
|
|
|
|
r->error_page = 1;
|
|
|
|
}
|
2004-12-21 20:30:30 +08:00
|
|
|
|
2003-11-10 04:03:38 +08:00
|
|
|
err_page = clcf->error_pages->elts;
|
2004-12-21 20:30:30 +08:00
|
|
|
|
2003-11-10 04:03:38 +08:00
|
|
|
for (i = 0; i < clcf->error_pages->nelts; i++) {
|
2004-04-26 04:13:21 +08:00
|
|
|
if (err_page[i].status == error) {
|
2007-10-27 00:17:17 +08:00
|
|
|
return ngx_http_send_error_page(r, &err_page[i]);
|
2003-11-10 04:03:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-26 21:43:42 +08:00
|
|
|
r->expect_tested = 1;
|
|
|
|
|
2008-08-19 20:23:18 +08:00
|
|
|
if (ngx_http_discard_request_body(r) != NGX_OK) {
|
|
|
|
error = NGX_HTTP_INTERNAL_SERVER_ERROR;
|
|
|
|
}
|
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
if (clcf->msie_refresh
|
|
|
|
&& r->headers_in.msie
|
|
|
|
&& (error == NGX_HTTP_MOVED_PERMANENTLY
|
|
|
|
|| error == NGX_HTTP_MOVED_TEMPORARILY))
|
|
|
|
{
|
|
|
|
return ngx_http_send_refresh(r);
|
|
|
|
}
|
|
|
|
|
2006-04-14 17:53:38 +08:00
|
|
|
if (error == NGX_HTTP_CREATED) {
|
|
|
|
/* 201 */
|
|
|
|
err = 0;
|
2006-04-19 23:30:56 +08:00
|
|
|
r->header_only = 1;
|
2006-04-14 17:53:38 +08:00
|
|
|
|
|
|
|
} else if (error == NGX_HTTP_NO_CONTENT) {
|
2005-05-15 02:42:03 +08:00
|
|
|
/* 204 */
|
|
|
|
err = 0;
|
|
|
|
|
2009-04-11 19:05:15 +08:00
|
|
|
} else if (error >= NGX_HTTP_MOVED_PERMANENTLY
|
|
|
|
&& error < NGX_HTTP_LAST_LEVEL_300)
|
|
|
|
{
|
2003-11-10 04:03:38 +08:00
|
|
|
/* 3XX */
|
2005-05-16 21:53:20 +08:00
|
|
|
err = error - NGX_HTTP_MOVED_PERMANENTLY + NGX_HTTP_LEVEL_200;
|
2003-11-10 04:03:38 +08:00
|
|
|
|
2009-04-11 19:05:15 +08:00
|
|
|
} else if (error >= NGX_HTTP_BAD_REQUEST
|
|
|
|
&& error < NGX_HTTP_LAST_LEVEL_400)
|
|
|
|
{
|
2003-11-10 04:03:38 +08:00
|
|
|
/* 4XX */
|
2005-05-15 02:42:03 +08:00
|
|
|
err = error - NGX_HTTP_BAD_REQUEST + NGX_HTTP_LEVEL_200
|
|
|
|
+ NGX_HTTP_LEVEL_300;
|
2003-11-10 04:03:38 +08:00
|
|
|
|
2009-04-11 19:05:15 +08:00
|
|
|
} else if (error >= NGX_HTTP_OWN_CODES
|
|
|
|
&& error < NGX_HTTP_LAST_LEVEL_500)
|
|
|
|
{
|
2004-05-15 00:51:47 +08:00
|
|
|
/* 49X, 5XX */
|
2005-12-07 22:51:31 +08:00
|
|
|
err = error - NGX_HTTP_OWN_CODES + NGX_HTTP_LEVEL_200
|
2005-05-15 02:42:03 +08:00
|
|
|
+ NGX_HTTP_LEVEL_300
|
2005-03-04 22:06:57 +08:00
|
|
|
+ NGX_HTTP_LEVEL_400;
|
2004-05-15 00:51:47 +08:00
|
|
|
switch (error) {
|
2004-07-09 15:12:14 +08:00
|
|
|
case NGX_HTTP_TO_HTTPS:
|
2006-05-07 00:28:56 +08:00
|
|
|
case NGX_HTTPS_CERT_ERROR:
|
|
|
|
case NGX_HTTPS_NO_CERT:
|
2006-08-29 00:57:48 +08:00
|
|
|
r->err_status = NGX_HTTP_BAD_REQUEST;
|
2004-07-09 15:12:14 +08:00
|
|
|
break;
|
2004-05-15 00:51:47 +08:00
|
|
|
}
|
2009-04-11 19:05:15 +08:00
|
|
|
|
|
|
|
} else {
|
|
|
|
/* unknown code, zero body */
|
|
|
|
err = 0;
|
2003-11-10 04:03:38 +08:00
|
|
|
}
|
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
return ngx_http_send_special_response(r, clcf, err);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-05-02 02:41:07 +08:00
|
|
|
ngx_int_t
|
2009-05-08 22:52:50 +08:00
|
|
|
ngx_http_filter_finalize_request(ngx_http_request_t *r, ngx_module_t *m,
|
|
|
|
ngx_int_t error)
|
2009-05-02 02:41:07 +08:00
|
|
|
{
|
2009-05-08 22:52:50 +08:00
|
|
|
void *ctx;
|
|
|
|
ngx_int_t rc;
|
2009-05-02 02:41:07 +08:00
|
|
|
|
|
|
|
ngx_http_clean_header(r);
|
|
|
|
|
2009-05-09 02:11:18 +08:00
|
|
|
ctx = NULL;
|
|
|
|
|
2009-05-08 22:52:50 +08:00
|
|
|
if (m) {
|
|
|
|
ctx = r->ctx[m->ctx_index];
|
|
|
|
}
|
|
|
|
|
2009-05-02 02:41:07 +08:00
|
|
|
/* clear the modules contexts */
|
|
|
|
ngx_memzero(r->ctx, sizeof(void *) * ngx_http_max_module);
|
|
|
|
|
2009-05-08 22:52:50 +08:00
|
|
|
if (m) {
|
|
|
|
r->ctx[m->ctx_index] = ctx;
|
|
|
|
}
|
|
|
|
|
2009-05-08 22:25:51 +08:00
|
|
|
r->filter_finalize = 1;
|
|
|
|
|
2009-05-02 02:41:07 +08:00
|
|
|
rc = ngx_http_special_response_handler(r, error);
|
|
|
|
|
|
|
|
/* NGX_ERROR resets any pending data */
|
|
|
|
|
2009-05-08 22:25:51 +08:00
|
|
|
switch (rc) {
|
|
|
|
|
|
|
|
case NGX_OK:
|
|
|
|
case NGX_DONE:
|
|
|
|
return NGX_ERROR;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return rc;
|
|
|
|
}
|
2009-05-02 02:41:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
ngx_http_clean_header(ngx_http_request_t *r)
|
|
|
|
{
|
|
|
|
ngx_memzero(&r->headers_out.status,
|
|
|
|
sizeof(ngx_http_headers_out_t)
|
|
|
|
- offsetof(ngx_http_headers_out_t, status));
|
|
|
|
|
|
|
|
r->headers_out.headers.part.nelts = 0;
|
|
|
|
r->headers_out.headers.part.next = NULL;
|
|
|
|
r->headers_out.headers.last = &r->headers_out.headers.part;
|
|
|
|
|
|
|
|
r->headers_out.content_length_n = -1;
|
|
|
|
r->headers_out.last_modified_time = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
static ngx_int_t
|
|
|
|
ngx_http_send_error_page(ngx_http_request_t *r, ngx_http_err_page_t *err_page)
|
|
|
|
{
|
2008-12-26 21:43:42 +08:00
|
|
|
ngx_int_t overwrite;
|
2009-03-22 17:40:04 +08:00
|
|
|
ngx_str_t uri, args;
|
2007-10-27 00:17:17 +08:00
|
|
|
ngx_table_elt_t *location;
|
|
|
|
ngx_http_core_loc_conf_t *clcf;
|
|
|
|
|
2008-12-26 21:43:42 +08:00
|
|
|
overwrite = err_page->overwrite;
|
|
|
|
|
|
|
|
if (overwrite && overwrite != NGX_HTTP_OK) {
|
|
|
|
r->expect_tested = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
r->err_status = overwrite;
|
2007-10-27 00:17:17 +08:00
|
|
|
|
|
|
|
r->zero_in_uri = 0;
|
|
|
|
|
2009-03-22 17:40:04 +08:00
|
|
|
if (ngx_http_complex_value(r, &err_page->value, &uri) != NGX_OK) {
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
2007-10-27 00:17:17 +08:00
|
|
|
|
2009-04-07 23:50:08 +08:00
|
|
|
if (uri.data[0] == '/') {
|
2007-10-27 00:17:17 +08:00
|
|
|
|
2009-04-07 23:50:08 +08:00
|
|
|
if (err_page->value.lengths) {
|
|
|
|
ngx_http_split_args(r, &uri, &args);
|
2007-10-27 00:17:17 +08:00
|
|
|
|
2009-04-07 23:50:08 +08:00
|
|
|
} else {
|
|
|
|
args = err_page->args;
|
|
|
|
}
|
2008-03-10 22:36:42 +08:00
|
|
|
|
2008-08-20 02:55:46 +08:00
|
|
|
if (r->method != NGX_HTTP_HEAD) {
|
|
|
|
r->method = NGX_HTTP_GET;
|
|
|
|
r->method_name = ngx_http_get_name;
|
|
|
|
}
|
2008-03-10 22:36:42 +08:00
|
|
|
|
2009-03-22 17:40:04 +08:00
|
|
|
return ngx_http_internal_redirect(r, &uri, &args);
|
2007-10-27 00:17:17 +08:00
|
|
|
}
|
|
|
|
|
2009-03-22 17:40:04 +08:00
|
|
|
if (uri.data[0] == '@') {
|
|
|
|
return ngx_http_named_location(r, &uri);
|
2007-10-27 00:17:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
location = ngx_list_push(&r->headers_out.headers);
|
|
|
|
|
|
|
|
if (location == NULL) {
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
r->err_status = NGX_HTTP_MOVED_TEMPORARILY;
|
|
|
|
|
|
|
|
location->hash = 1;
|
|
|
|
location->key.len = sizeof("Location") - 1;
|
|
|
|
location->key.data = (u_char *) "Location";
|
2009-03-22 17:40:04 +08:00
|
|
|
location->value = uri;
|
2007-10-27 00:17:17 +08:00
|
|
|
|
|
|
|
r->headers_out.location = location;
|
|
|
|
|
|
|
|
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
|
|
|
|
|
|
|
|
if (clcf->msie_refresh && r->headers_in.msie) {
|
|
|
|
return ngx_http_send_refresh(r);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ngx_http_send_special_response(r, clcf, NGX_HTTP_MOVED_TEMPORARILY
|
|
|
|
- NGX_HTTP_MOVED_PERMANENTLY
|
|
|
|
+ NGX_HTTP_LEVEL_200);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static ngx_int_t
|
|
|
|
ngx_http_send_special_response(ngx_http_request_t *r,
|
|
|
|
ngx_http_core_loc_conf_t *clcf, ngx_uint_t err)
|
|
|
|
{
|
|
|
|
u_char *tail;
|
|
|
|
size_t len;
|
|
|
|
ngx_int_t rc;
|
|
|
|
ngx_buf_t *b;
|
|
|
|
ngx_uint_t msie_padding;
|
|
|
|
ngx_chain_t out[3];
|
|
|
|
|
|
|
|
if (clcf->server_tokens) {
|
|
|
|
len = sizeof(ngx_http_error_full_tail) - 1;
|
|
|
|
tail = ngx_http_error_full_tail;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
len = sizeof(ngx_http_error_tail) - 1;
|
|
|
|
tail = ngx_http_error_tail;
|
|
|
|
}
|
|
|
|
|
2004-06-16 23:32:11 +08:00
|
|
|
msie_padding = 0;
|
|
|
|
|
2006-10-02 18:22:51 +08:00
|
|
|
if (!r->zero_body) {
|
2007-10-27 00:17:17 +08:00
|
|
|
if (ngx_http_error_pages[err].len) {
|
|
|
|
r->headers_out.content_length_n = ngx_http_error_pages[err].len
|
|
|
|
+ len;
|
2006-10-02 18:22:51 +08:00
|
|
|
if (clcf->msie_padding
|
|
|
|
&& r->headers_in.msie
|
|
|
|
&& r->http_version >= NGX_HTTP_VERSION_10
|
2007-10-27 00:17:17 +08:00
|
|
|
&& err >= NGX_HTTP_LEVEL_300)
|
2006-10-02 18:22:51 +08:00
|
|
|
{
|
|
|
|
r->headers_out.content_length_n +=
|
|
|
|
sizeof(ngx_http_msie_stub) - 1;
|
|
|
|
msie_padding = 1;
|
|
|
|
}
|
2003-06-02 23:24:30 +08:00
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
r->headers_out.content_type_len = sizeof("text/html") - 1;
|
2006-10-02 18:22:51 +08:00
|
|
|
r->headers_out.content_type.len = sizeof("text/html") - 1;
|
|
|
|
r->headers_out.content_type.data = (u_char *) "text/html";
|
|
|
|
|
|
|
|
} else {
|
|
|
|
r->headers_out.content_length_n = -1;
|
|
|
|
}
|
2003-06-02 23:24:30 +08:00
|
|
|
|
|
|
|
} else {
|
2006-10-02 18:22:51 +08:00
|
|
|
r->headers_out.content_length_n = 0;
|
|
|
|
err = 0;
|
2003-10-30 01:39:05 +08: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 22:58:06 +08:00
|
|
|
r->headers_out.content_length->hash = 0;
|
2003-10-22 00:49:56 +08:00
|
|
|
r->headers_out.content_length = NULL;
|
2003-03-13 01:32:22 +08:00
|
|
|
}
|
2002-12-15 14:25:09 +08:00
|
|
|
|
2005-11-15 21:30:52 +08:00
|
|
|
ngx_http_clear_accept_ranges(r);
|
|
|
|
ngx_http_clear_last_modified(r);
|
|
|
|
|
2003-06-11 23:28:34 +08:00
|
|
|
rc = ngx_http_send_header(r);
|
2003-10-09 15:00:45 +08:00
|
|
|
|
2003-10-10 23:10:50 +08:00
|
|
|
if (rc == NGX_ERROR || r->header_only) {
|
|
|
|
return rc;
|
2003-06-11 23:28:34 +08:00
|
|
|
}
|
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
if (ngx_http_error_pages[err].len == 0) {
|
|
|
|
return NGX_OK;
|
|
|
|
}
|
2005-03-19 20:38:37 +08:00
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
b = ngx_calloc_buf(r->pool);
|
|
|
|
if (b == NULL) {
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
2002-12-15 14:25:09 +08:00
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
b->memory = 1;
|
|
|
|
b->pos = ngx_http_error_pages[err].data;
|
|
|
|
b->last = ngx_http_error_pages[err].data + ngx_http_error_pages[err].len;
|
2002-12-11 02:05:12 +08:00
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
out[0].buf = b;
|
|
|
|
out[0].next = &out[1];
|
2003-06-11 23:28:34 +08:00
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
b = ngx_calloc_buf(r->pool);
|
|
|
|
if (b == NULL) {
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
2005-03-19 20:38:37 +08:00
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
b->memory = 1;
|
2003-06-11 23:28:34 +08:00
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
b->pos = tail;
|
|
|
|
b->last = tail + len;
|
2005-03-19 20:38:37 +08:00
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
out[1].buf = b;
|
2008-05-22 20:09:41 +08:00
|
|
|
out[1].next = NULL;
|
2003-10-22 00:49:56 +08:00
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
if (msie_padding) {
|
2005-03-19 20:38:37 +08:00
|
|
|
b = ngx_calloc_buf(r->pool);
|
|
|
|
if (b == NULL) {
|
2003-10-29 16:30:44 +08:00
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
2005-03-19 20:38:37 +08:00
|
|
|
|
2004-05-28 23:49:23 +08:00
|
|
|
b->memory = 1;
|
2007-10-27 00:17:17 +08:00
|
|
|
b->pos = ngx_http_msie_stub;
|
|
|
|
b->last = ngx_http_msie_stub + sizeof(ngx_http_msie_stub) - 1;
|
2007-10-22 18:17:34 +08:00
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
out[1].next = &out[2];
|
|
|
|
out[2].buf = b;
|
2008-05-22 20:09:41 +08:00
|
|
|
out[2].next = NULL;
|
2007-10-27 00:17:17 +08:00
|
|
|
}
|
2005-03-19 20:38:37 +08:00
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
if (r == r->main) {
|
|
|
|
b->last_buf = 1;
|
|
|
|
}
|
2003-10-22 00:49:56 +08:00
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
b->last_in_chain = 1;
|
2006-08-29 00:57:48 +08:00
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
return ngx_http_output_filter(r, &out[0]);
|
|
|
|
}
|
2006-08-29 00:57:48 +08:00
|
|
|
|
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
static ngx_int_t
|
|
|
|
ngx_http_send_refresh(ngx_http_request_t *r)
|
|
|
|
{
|
|
|
|
u_char *p, *location;
|
|
|
|
size_t len, size;
|
|
|
|
uintptr_t escape;
|
|
|
|
ngx_int_t rc;
|
|
|
|
ngx_buf_t *b;
|
|
|
|
ngx_chain_t out;
|
2006-08-29 00:57:48 +08:00
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
len = r->headers_out.location->value.len;
|
|
|
|
location = r->headers_out.location->value.data;
|
2006-08-29 00:57:48 +08:00
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
escape = 2 * ngx_escape_uri(NULL, location, len, NGX_ESCAPE_REFRESH);
|
2006-08-29 00:57:48 +08:00
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
size = sizeof(ngx_http_msie_refresh_head) - 1
|
|
|
|
+ escape + len
|
|
|
|
+ sizeof(ngx_http_msie_refresh_tail) - 1;
|
2006-08-29 00:57:48 +08:00
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
r->err_status = NGX_HTTP_OK;
|
2007-07-13 17:37:01 +08:00
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
r->headers_out.content_type_len = sizeof("text/html") - 1;
|
|
|
|
r->headers_out.content_type.len = sizeof("text/html") - 1;
|
|
|
|
r->headers_out.content_type.data = (u_char *) "text/html";
|
2006-08-29 00:57:48 +08:00
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
r->headers_out.location->hash = 0;
|
|
|
|
r->headers_out.location = NULL;
|
2006-08-29 00:57:48 +08:00
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
r->headers_out.content_length_n = size;
|
|
|
|
|
|
|
|
if (r->headers_out.content_length) {
|
|
|
|
r->headers_out.content_length->hash = 0;
|
|
|
|
r->headers_out.content_length = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ngx_http_clear_accept_ranges(r);
|
|
|
|
ngx_http_clear_last_modified(r);
|
2006-08-29 00:57:48 +08:00
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
rc = ngx_http_send_header(r);
|
|
|
|
|
|
|
|
if (rc == NGX_ERROR || r->header_only) {
|
|
|
|
return rc;
|
2003-06-11 23:28:34 +08:00
|
|
|
}
|
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
b = ngx_create_temp_buf(r->pool, size);
|
|
|
|
if (b == NULL) {
|
|
|
|
return NGX_ERROR;
|
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 22:58:06 +08:00
|
|
|
}
|
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
p = ngx_cpymem(b->pos, ngx_http_msie_refresh_head,
|
|
|
|
sizeof(ngx_http_msie_refresh_head) - 1);
|
|
|
|
|
|
|
|
if (escape == 0) {
|
|
|
|
p = ngx_cpymem(p, location, len);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
p = (u_char *) ngx_escape_uri(p, location, len, NGX_ESCAPE_REFRESH);
|
|
|
|
}
|
|
|
|
|
|
|
|
b->last = ngx_cpymem(p, ngx_http_msie_refresh_tail,
|
|
|
|
sizeof(ngx_http_msie_refresh_tail) - 1);
|
|
|
|
|
|
|
|
b->last_buf = 1;
|
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 22:58:06 +08:00
|
|
|
b->last_in_chain = 1;
|
2003-06-11 23:28:34 +08:00
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
out.buf = b;
|
|
|
|
out.next = NULL;
|
2005-03-19 20:38:37 +08:00
|
|
|
|
2007-10-27 00:17:17 +08:00
|
|
|
return ngx_http_output_filter(r, &out);
|
2002-12-11 02:05:12 +08:00
|
|
|
}
|