Mercurial > hg > nginx
comparison src/http/ngx_http_request.c @ 408:d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 27 Aug 2004 15:40:59 +0000 |
parents | ba0809223309 |
children | 3c56e834be46 |
comparison
equal
deleted
inserted
replaced
407:35fe251cd231 | 408:d6e2b445c1b8 |
---|---|
615 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); | 615 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
616 ngx_http_close_connection(c); | 616 ngx_http_close_connection(c); |
617 return; | 617 return; |
618 } | 618 } |
619 | 619 |
620 /* r->headers_in.headers.elts = NULL; */ | |
621 /* r->headers_in.headers.nelts = 0; */ | 620 /* r->headers_in.headers.nelts = 0; */ |
622 r->headers_in.headers.size = sizeof(ngx_table_elt_t); | 621 r->headers_in.headers.size = sizeof(ngx_table_elt_t); |
623 r->headers_in.headers.nalloc = 20; | 622 r->headers_in.headers.nalloc = 20; |
624 r->headers_in.headers.pool = r->pool; | 623 r->headers_in.headers.pool = r->pool; |
624 | |
625 | |
626 /* init the r->headers_in.cookies array */ | |
627 | |
628 r->headers_in.cookies.elts = ngx_pcalloc(r->pool, | |
629 5 * sizeof(ngx_uint_t)); | |
630 if (r->headers_in.cookies.elts == NULL) { | |
631 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); | |
632 ngx_http_close_connection(c); | |
633 return; | |
634 } | |
635 | |
636 /* r->headers_in.cookies.nelts = 0; */ | |
637 r->headers_in.cookies.size = sizeof(ngx_uint_t); | |
638 r->headers_in.cookies.nalloc = 5; | |
639 r->headers_in.cookies.pool = r->pool; | |
640 | |
625 | 641 |
626 ctx = c->log->data; | 642 ctx = c->log->data; |
627 ctx->action = "reading client request headers"; | 643 ctx->action = "reading client request headers"; |
628 ctx->url = r->unparsed_uri.data; | 644 ctx->url = r->unparsed_uri.data; |
629 | 645 |
713 | 729 |
714 static void ngx_http_process_request_headers(ngx_event_t *rev) | 730 static void ngx_http_process_request_headers(ngx_event_t *rev) |
715 { | 731 { |
716 ssize_t n; | 732 ssize_t n; |
717 ngx_int_t rc, i, offset; | 733 ngx_int_t rc, i, offset; |
734 ngx_uint_t *cookie; | |
718 ngx_table_elt_t *h; | 735 ngx_table_elt_t *h; |
719 ngx_connection_t *c; | 736 ngx_connection_t *c; |
720 ngx_http_request_t *r; | 737 ngx_http_request_t *r; |
721 ngx_http_core_srv_conf_t *cscf; | 738 ngx_http_core_srv_conf_t *cscf; |
722 | 739 |
781 h->key.data[h->key.len] = '\0'; | 798 h->key.data[h->key.len] = '\0'; |
782 h->value.data = r->header_start; | 799 h->value.data = r->header_start; |
783 h->value.data[h->value.len] = '\0'; | 800 h->value.data[h->value.len] = '\0'; |
784 } | 801 } |
785 | 802 |
786 for (i = 0; ngx_http_headers_in[i].name.len != 0; i++) { | 803 if (h->key.len == sizeof("Cookie") - 1 |
787 if (ngx_http_headers_in[i].name.len != h->key.len) { | 804 && ngx_strcasecmp(h->key.data, "Cookie") == 0) |
788 continue; | 805 { |
806 if (!(cookie = ngx_push_array(&r->headers_in.cookies))) { | |
807 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); | |
808 ngx_http_close_connection(c); | |
809 return; | |
789 } | 810 } |
790 | 811 |
791 if (ngx_strcasecmp(ngx_http_headers_in[i].name.data, | 812 *cookie = r->headers_in.headers.nelts - 1; |
792 h->key.data) == 0) | 813 |
793 { | 814 } else { |
794 *((ngx_table_elt_t **) ((char *) &r->headers_in | 815 |
816 for (i = 0; ngx_http_headers_in[i].name.len != 0; i++) { | |
817 if (ngx_http_headers_in[i].name.len != h->key.len) { | |
818 continue; | |
819 } | |
820 | |
821 if (ngx_strcasecmp(ngx_http_headers_in[i].name.data, | |
822 h->key.data) == 0) | |
823 { | |
824 *((ngx_table_elt_t **) ((char *) &r->headers_in | |
795 + ngx_http_headers_in[i].offset)) = h; | 825 + ngx_http_headers_in[i].offset)) = h; |
796 break; | 826 break; |
827 } | |
797 } | 828 } |
798 } | 829 } |
799 | 830 |
800 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 831 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
801 "http header: \"%s: %s\"", | 832 "http header: \"%s: %s\"", |