comparison src/http/ngx_http_special_response.c @ 464:c8cfb6c462ef NGINX_0_7_44

nginx 0.7.44 *) Feature: the ngx_http_proxy_module preliminary cache support. *) Feature: the --with-pcre option in the configure. *) Feature: the "try_files" directive is now allowed on the server block level. *) Bugfix: the "try_files" directive handled incorrectly a query string in a fallback parameter. *) Bugfix: the "try_files" directive might test incorrectly directories. *) Bugfix: if there is the single server for given address:port pair, then captures in regular expressions in a "server_name" directive did not work.
author Igor Sysoev <http://sysoev.ru>
date Mon, 23 Mar 2009 00:00:00 +0300
parents ce4f9ff90bfa
children f2c6a7373274
comparison
equal deleted inserted replaced
463:51cb914e6d3a 464:c8cfb6c462ef
430 430
431 431
432 static ngx_int_t 432 static ngx_int_t
433 ngx_http_send_error_page(ngx_http_request_t *r, ngx_http_err_page_t *err_page) 433 ngx_http_send_error_page(ngx_http_request_t *r, ngx_http_err_page_t *err_page)
434 { 434 {
435 u_char ch, *p, *last;
436 ngx_int_t overwrite; 435 ngx_int_t overwrite;
437 ngx_str_t *uri, *args, u, a; 436 ngx_str_t uri, args;
438 ngx_table_elt_t *location; 437 ngx_table_elt_t *location;
439 ngx_http_core_loc_conf_t *clcf; 438 ngx_http_core_loc_conf_t *clcf;
440 439
441 overwrite = err_page->overwrite; 440 overwrite = err_page->overwrite;
442 441
446 445
447 r->err_status = overwrite; 446 r->err_status = overwrite;
448 447
449 r->zero_in_uri = 0; 448 r->zero_in_uri = 0;
450 449
451 if (err_page->uri_lengths) { 450 if (ngx_http_complex_value(r, &err_page->value, &uri) != NGX_OK) {
452 if (ngx_http_script_run(r, &u, err_page->uri_lengths->elts, 0, 451 return NGX_ERROR;
453 err_page->uri_values->elts) 452 }
454 == NULL) 453
455 { 454 if (err_page->value.lengths) {
456 return NGX_ERROR; 455 ngx_http_split_args(r, &uri, &args);
457 }
458
459 p = u.data;
460 uri = &u;
461 args = NULL;
462
463 if (*p == '/') {
464
465 last = p + uri->len;
466
467 while (p < last) {
468
469 ch = *p++;
470
471 if (ch == '?') {
472 a.len = last - p;
473 a.data = p;
474 args = &a;
475
476 u.len = p - 1 - u.data;
477
478 while (p < last) {
479 if (*p++ == '\0') {
480 r->zero_in_uri = 1;
481 break;
482 }
483 }
484
485 break;
486 }
487
488 if (ch == '\0') {
489 r->zero_in_uri = 1;
490 continue;
491 }
492 }
493 }
494 456
495 } else { 457 } else {
496 uri = &err_page->uri; 458 args = err_page->args;
497 args = &err_page->args; 459 }
498 } 460
499 461 if (uri.data[0] == '/') {
500 if (uri->data[0] == '/') {
501 462
502 if (r->method != NGX_HTTP_HEAD) { 463 if (r->method != NGX_HTTP_HEAD) {
503 r->method = NGX_HTTP_GET; 464 r->method = NGX_HTTP_GET;
504 r->method_name = ngx_http_get_name; 465 r->method_name = ngx_http_get_name;
505 } 466 }
506 467
507 return ngx_http_internal_redirect(r, uri, args); 468 return ngx_http_internal_redirect(r, &uri, &args);
508 } 469 }
509 470
510 if (uri->data[0] == '@') { 471 if (uri.data[0] == '@') {
511 return ngx_http_named_location(r, uri); 472 return ngx_http_named_location(r, &uri);
512 } 473 }
513 474
514 location = ngx_list_push(&r->headers_out.headers); 475 location = ngx_list_push(&r->headers_out.headers);
515 476
516 if (location == NULL) { 477 if (location == NULL) {
520 r->err_status = NGX_HTTP_MOVED_TEMPORARILY; 481 r->err_status = NGX_HTTP_MOVED_TEMPORARILY;
521 482
522 location->hash = 1; 483 location->hash = 1;
523 location->key.len = sizeof("Location") - 1; 484 location->key.len = sizeof("Location") - 1;
524 location->key.data = (u_char *) "Location"; 485 location->key.data = (u_char *) "Location";
525 location->value = *uri; 486 location->value = uri;
526 487
527 r->headers_out.location = location; 488 r->headers_out.location = location;
528 489
529 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); 490 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
530 491