comparison src/http/ngx_http_special_response.c @ 2696:ae4744c28620

allow any status
author Igor Sysoev <igor@sysoev.ru>
date Sat, 11 Apr 2009 11:05:15 +0000
parents 6c8a5165ed2a
children 3daf68f2efe3
comparison
equal deleted inserted replaced
2695:aa95c69c3068 2696:ae4744c28620
273 273
274 static ngx_str_t ngx_http_error_pages[] = { 274 static ngx_str_t ngx_http_error_pages[] = {
275 275
276 ngx_null_string, /* 201, 204 */ 276 ngx_null_string, /* 201, 204 */
277 277
278 #define NGX_HTTP_LEVEL_200 1 278 #define NGX_HTTP_LAST_LEVEL_200 202
279 #define NGX_HTTP_LEVEL_200 (NGX_HTTP_LAST_LEVEL_200 - 201)
279 280
280 /* ngx_null_string, */ /* 300 */ 281 /* ngx_null_string, */ /* 300 */
281 ngx_string(ngx_http_error_301_page), 282 ngx_string(ngx_http_error_301_page),
282 ngx_string(ngx_http_error_302_page), 283 ngx_string(ngx_http_error_302_page),
283 ngx_null_string, /* 303 */ 284 ngx_null_string, /* 303 */
284 285
285 #define NGX_HTTP_LEVEL_300 3 286 #define NGX_HTTP_LAST_LEVEL_300 304
287 #define NGX_HTTP_LEVEL_300 (NGX_HTTP_LAST_LEVEL_300 - 301)
286 288
287 ngx_string(ngx_http_error_400_page), 289 ngx_string(ngx_http_error_400_page),
288 ngx_string(ngx_http_error_401_page), 290 ngx_string(ngx_http_error_401_page),
289 ngx_string(ngx_http_error_402_page), 291 ngx_string(ngx_http_error_402_page),
290 ngx_string(ngx_http_error_403_page), 292 ngx_string(ngx_http_error_403_page),
300 ngx_string(ngx_http_error_413_page), 302 ngx_string(ngx_http_error_413_page),
301 ngx_string(ngx_http_error_414_page), 303 ngx_string(ngx_http_error_414_page),
302 ngx_string(ngx_http_error_415_page), 304 ngx_string(ngx_http_error_415_page),
303 ngx_string(ngx_http_error_416_page), 305 ngx_string(ngx_http_error_416_page),
304 306
305 #define NGX_HTTP_LEVEL_400 17 307 #define NGX_HTTP_LAST_LEVEL_400 417
308 #define NGX_HTTP_LEVEL_400 (NGX_HTTP_LAST_LEVEL_400 - 400)
306 309
307 ngx_string(ngx_http_error_495_page), /* 495, https certificate error */ 310 ngx_string(ngx_http_error_495_page), /* 495, https certificate error */
308 ngx_string(ngx_http_error_496_page), /* 496, https no certificate */ 311 ngx_string(ngx_http_error_496_page), /* 496, https no certificate */
309 ngx_string(ngx_http_error_497_page), /* 497, http to https */ 312 ngx_string(ngx_http_error_497_page), /* 497, http to https */
310 ngx_string(ngx_http_error_404_page), /* 498, canceled */ 313 ngx_string(ngx_http_error_404_page), /* 498, canceled */
316 ngx_string(ngx_http_error_503_page), 319 ngx_string(ngx_http_error_503_page),
317 ngx_string(ngx_http_error_504_page), 320 ngx_string(ngx_http_error_504_page),
318 ngx_null_string, /* 505 */ 321 ngx_null_string, /* 505 */
319 ngx_null_string, /* 506 */ 322 ngx_null_string, /* 506 */
320 ngx_string(ngx_http_error_507_page) 323 ngx_string(ngx_http_error_507_page)
324
325 #define NGX_HTTP_LAST_LEVEL_500 508
326
321 }; 327 };
322 328
323 329
324 static ngx_str_t ngx_http_get_name = { 3, (u_char *) "GET " }; 330 static ngx_str_t ngx_http_get_name = { 3, (u_char *) "GET " };
325 331
400 406
401 } else if (error == NGX_HTTP_NO_CONTENT) { 407 } else if (error == NGX_HTTP_NO_CONTENT) {
402 /* 204 */ 408 /* 204 */
403 err = 0; 409 err = 0;
404 410
405 } else if (error < NGX_HTTP_BAD_REQUEST) { 411 } else if (error >= NGX_HTTP_MOVED_PERMANENTLY
412 && error < NGX_HTTP_LAST_LEVEL_300)
413 {
406 /* 3XX */ 414 /* 3XX */
407 err = error - NGX_HTTP_MOVED_PERMANENTLY + NGX_HTTP_LEVEL_200; 415 err = error - NGX_HTTP_MOVED_PERMANENTLY + NGX_HTTP_LEVEL_200;
408 416
409 } else if (error < NGX_HTTP_OWN_CODES) { 417 } else if (error >= NGX_HTTP_BAD_REQUEST
418 && error < NGX_HTTP_LAST_LEVEL_400)
419 {
410 /* 4XX */ 420 /* 4XX */
411 err = error - NGX_HTTP_BAD_REQUEST + NGX_HTTP_LEVEL_200 421 err = error - NGX_HTTP_BAD_REQUEST + NGX_HTTP_LEVEL_200
412 + NGX_HTTP_LEVEL_300; 422 + NGX_HTTP_LEVEL_300;
413 423
414 } else { 424 } else if (error >= NGX_HTTP_OWN_CODES
425 && error < NGX_HTTP_LAST_LEVEL_500)
426 {
415 /* 49X, 5XX */ 427 /* 49X, 5XX */
416 err = error - NGX_HTTP_OWN_CODES + NGX_HTTP_LEVEL_200 428 err = error - NGX_HTTP_OWN_CODES + NGX_HTTP_LEVEL_200
417 + NGX_HTTP_LEVEL_300 429 + NGX_HTTP_LEVEL_300
418 + NGX_HTTP_LEVEL_400; 430 + NGX_HTTP_LEVEL_400;
419 switch (error) { 431 switch (error) {
421 case NGX_HTTPS_CERT_ERROR: 433 case NGX_HTTPS_CERT_ERROR:
422 case NGX_HTTPS_NO_CERT: 434 case NGX_HTTPS_NO_CERT:
423 r->err_status = NGX_HTTP_BAD_REQUEST; 435 r->err_status = NGX_HTTP_BAD_REQUEST;
424 break; 436 break;
425 } 437 }
438
439 } else {
440 /* unknown code, zero body */
441 err = 0;
426 } 442 }
427 443
428 return ngx_http_send_special_response(r, clcf, err); 444 return ngx_http_send_special_response(r, clcf, err);
429 } 445 }
430 446