comparison src/http/ngx_http_special_response.c @ 6451:155871d773cc

Backed out server_tokens changes. Backed out changesets: cf3e75cfa951, 6b72414dfb4f, 602dc42035fe, e5076b96fd01.
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 22 Mar 2016 16:58:38 +0300
parents e5076b96fd01
children 654d2dae97d3
comparison
equal deleted inserted replaced
6450:22c32937a41f 6451:155871d773cc
607 607
608 static ngx_int_t 608 static ngx_int_t
609 ngx_http_send_special_response(ngx_http_request_t *r, 609 ngx_http_send_special_response(ngx_http_request_t *r,
610 ngx_http_core_loc_conf_t *clcf, ngx_uint_t err) 610 ngx_http_core_loc_conf_t *clcf, ngx_uint_t err)
611 { 611 {
612 u_char *tail;
613 size_t len;
612 ngx_int_t rc; 614 ngx_int_t rc;
613 ngx_str_t tail, tokens;
614 ngx_buf_t *b; 615 ngx_buf_t *b;
615 ngx_uint_t msie_padding; 616 ngx_uint_t msie_padding;
616 ngx_chain_t out[3]; 617 ngx_chain_t out[3];
617 618
619 if (clcf->server_tokens) {
620 len = sizeof(ngx_http_error_full_tail) - 1;
621 tail = ngx_http_error_full_tail;
622
623 } else {
624 len = sizeof(ngx_http_error_tail) - 1;
625 tail = ngx_http_error_tail;
626 }
627
618 msie_padding = 0; 628 msie_padding = 0;
619 629
620 if (ngx_http_error_pages[err].len) { 630 if (ngx_http_error_pages[err].len) {
621 631 r->headers_out.content_length_n = ngx_http_error_pages[err].len + len;
622 if (clcf->server_tokens == 0) {
623 ngx_str_set(&tail, ngx_http_error_tail);
624
625 } else if (clcf->server_tokens == 1) {
626 ngx_str_set(&tail, ngx_http_error_full_tail);
627
628 } else {
629 if (ngx_http_complex_value(r, &clcf->server_tokens_value, &tokens)
630 != NGX_OK)
631 {
632 return NGX_ERROR;
633 }
634
635 if (tokens.len == 0
636 || (tokens.len == 3 && ngx_strncmp(tokens.data, "off", 3) == 0))
637 {
638 ngx_str_set(&tail, ngx_http_error_tail);
639
640 } else {
641 ngx_str_set(&tail, ngx_http_error_full_tail);
642 }
643 }
644
645 r->headers_out.content_length_n = ngx_http_error_pages[err].len
646 + tail.len;
647
648 if (clcf->msie_padding 632 if (clcf->msie_padding
649 && (r->headers_in.msie || r->headers_in.chrome) 633 && (r->headers_in.msie || r->headers_in.chrome)
650 && r->http_version >= NGX_HTTP_VERSION_10 634 && r->http_version >= NGX_HTTP_VERSION_10
651 && err >= NGX_HTTP_OFF_4XX) 635 && err >= NGX_HTTP_OFF_4XX)
652 { 636 {
659 ngx_str_set(&r->headers_out.content_type, "text/html"); 643 ngx_str_set(&r->headers_out.content_type, "text/html");
660 r->headers_out.content_type_lowcase = NULL; 644 r->headers_out.content_type_lowcase = NULL;
661 645
662 } else { 646 } else {
663 r->headers_out.content_length_n = 0; 647 r->headers_out.content_length_n = 0;
664
665 #if (NGX_SUPPRESS_WARN)
666 ngx_str_null(&tail);
667 #endif
668 } 648 }
669 649
670 if (r->headers_out.content_length) { 650 if (r->headers_out.content_length) {
671 r->headers_out.content_length->hash = 0; 651 r->headers_out.content_length->hash = 0;
672 r->headers_out.content_length = NULL; 652 r->headers_out.content_length = NULL;
702 if (b == NULL) { 682 if (b == NULL) {
703 return NGX_ERROR; 683 return NGX_ERROR;
704 } 684 }
705 685
706 b->memory = 1; 686 b->memory = 1;
707 b->pos = tail.data; 687
708 b->last = tail.data + tail.len; 688 b->pos = tail;
689 b->last = tail + len;
709 690
710 out[1].buf = b; 691 out[1].buf = b;
711 out[1].next = NULL; 692 out[1].next = NULL;
712 693
713 if (msie_padding) { 694 if (msie_padding) {