Klaus Demo nginx / 1c57fb8
Added support for the 307 Temporary Redirect. Ruslan Ermilov 10 years ago
6 changed file(s) with 36 addition(s) and 16 deletion(s). Raw diff Collapse all Expand all
148148 && r->headers_out.status != NGX_HTTP_PARTIAL_CONTENT
149149 && r->headers_out.status != NGX_HTTP_MOVED_PERMANENTLY
150150 && r->headers_out.status != NGX_HTTP_MOVED_TEMPORARILY
151 && r->headers_out.status != NGX_HTTP_NOT_MODIFIED))
151 && r->headers_out.status != NGX_HTTP_SEE_OTHER
152 && r->headers_out.status != NGX_HTTP_NOT_MODIFIED
153 && r->headers_out.status != NGX_HTTP_TEMPORARY_REDIRECT))
152154 {
153155 return ngx_http_next_header_filter(r);
154156 }
2020 HTTP_MOVED_PERMANENTLY
2121 HTTP_MOVED_TEMPORARILY
2222 HTTP_REDIRECT
23 HTTP_SEE_OTHER
2324 HTTP_NOT_MODIFIED
25 HTTP_TEMPORARY_REDIRECT
2426
2527 HTTP_BAD_REQUEST
2628 HTTP_UNAUTHORIZED
6668 use constant HTTP_MOVED_PERMANENTLY => 301;
6769 use constant HTTP_MOVED_TEMPORARILY => 302;
6870 use constant HTTP_REDIRECT => 302;
71 use constant HTTP_SEE_OTHER => 303;
6972 use constant HTTP_NOT_MODIFIED => 304;
73 use constant HTTP_TEMPORARY_REDIRECT => 307;
7074
7175 use constant HTTP_BAD_REQUEST => 400;
7276 use constant HTTP_UNAUTHORIZED => 401;
18231823 return NGX_HTTP_INTERNAL_SERVER_ERROR;
18241824 }
18251825
1826 if (status >= NGX_HTTP_MOVED_PERMANENTLY && status <= NGX_HTTP_SEE_OTHER) {
1827
1826 if (status == NGX_HTTP_MOVED_PERMANENTLY
1827 || status == NGX_HTTP_MOVED_TEMPORARILY
1828 || status == NGX_HTTP_SEE_OTHER
1829 || status == NGX_HTTP_TEMPORARY_REDIRECT)
1830 {
18281831 ngx_http_clear_location(r);
18291832
18301833 r->headers_out.location = ngx_list_push(&r->headers_out.headers);
7070 ngx_string("302 Moved Temporarily"),
7171 ngx_string("303 See Other"),
7272 ngx_string("304 Not Modified"),
73
74 /* ngx_null_string, */ /* "305 Use Proxy" */
75 /* ngx_null_string, */ /* "306 unused" */
76 /* ngx_null_string, */ /* "307 Temporary Redirect" */
77
78 #define NGX_HTTP_LAST_3XX 305
73 ngx_null_string, /* "305 Use Proxy" */
74 ngx_null_string, /* "306 unused" */
75 ngx_string("307 Temporary Redirect"),
76
77 #define NGX_HTTP_LAST_3XX 308
7978 #define NGX_HTTP_OFF_4XX (NGX_HTTP_LAST_3XX - 301 + NGX_HTTP_OFF_3XX)
8079
8180 ngx_string("400 Bad Request"),
7474 #define NGX_HTTP_MOVED_TEMPORARILY 302
7575 #define NGX_HTTP_SEE_OTHER 303
7676 #define NGX_HTTP_NOT_MODIFIED 304
77 #define NGX_HTTP_TEMPORARY_REDIRECT 307
7778
7879 #define NGX_HTTP_BAD_REQUEST 400
7980 #define NGX_HTTP_UNAUTHORIZED 401
7373 ;
7474
7575
76 static char ngx_http_error_307_page[] =
77 "<html>" CRLF
78 "<head><title>307 Temporary Redirect</title></head>" CRLF
79 "<body bgcolor=\"white\">" CRLF
80 "<center><h1>307 Temporary Redirect</h1></center>" CRLF
81 ;
82
83
7684 static char ngx_http_error_400_page[] =
7785 "<html>" CRLF
7886 "<head><title>400 Bad Request</title></head>" CRLF
300308 ngx_string(ngx_http_error_301_page),
301309 ngx_string(ngx_http_error_302_page),
302310 ngx_string(ngx_http_error_303_page),
303
304 #define NGX_HTTP_LAST_3XX 304
311 ngx_null_string, /* 304 */
312 ngx_null_string, /* 305 */
313 ngx_null_string, /* 306 */
314 ngx_string(ngx_http_error_307_page),
315
316 #define NGX_HTTP_LAST_3XX 308
305317 #define NGX_HTTP_OFF_4XX (NGX_HTTP_LAST_3XX - 301 + NGX_HTTP_OFF_3XX)
306318
307319 ngx_string(ngx_http_error_400_page),
566578 return NGX_ERROR;
567579 }
568580
569 if (overwrite >= NGX_HTTP_MOVED_PERMANENTLY
570 && overwrite <= NGX_HTTP_SEE_OTHER)
581 if (overwrite != NGX_HTTP_MOVED_PERMANENTLY
582 && overwrite != NGX_HTTP_MOVED_TEMPORARILY
583 && overwrite != NGX_HTTP_SEE_OTHER
584 && overwrite != NGX_HTTP_TEMPORARY_REDIRECT)
571585 {
572 r->err_status = overwrite;
573
574 } else {
575586 r->err_status = NGX_HTTP_MOVED_TEMPORARILY;
576587 }
577588