Mercurial > hg > nginx
comparison src/http/ngx_http_event.c @ 82:fccdb921e8b8
nginx-0.0.1-2003-04-25-18:43:13 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 25 Apr 2003 14:43:13 +0000 |
parents | 57c2e18d3572 |
children | 3973260705cc |
comparison
equal
deleted
inserted
replaced
81:b2ece31c976a | 82:fccdb921e8b8 |
---|---|
45 "client %s sent too long URI", | 45 "client %s sent too long URI", |
46 "client %s sent HEAD method in HTTP/0.9 request", | 46 "client %s sent HEAD method in HTTP/0.9 request", |
47 | 47 |
48 "client %s sent invalid header, URL: %s", | 48 "client %s sent invalid header, URL: %s", |
49 "client %s sent too long header line, URL: %s", | 49 "client %s sent too long header line, URL: %s", |
50 "client %s sent HTTP/1.1 request without \"Host\" header, URL: %s" | 50 "client %s sent HTTP/1.1 request without \"Host\" header, URL: %s", |
51 "client %s sent invalid \"Content-Length\" header, URL: %s" | |
51 }; | 52 }; |
52 | 53 |
53 | 54 |
54 | 55 |
55 static ngx_http_header_t headers_in[] = { | 56 static ngx_http_header_t headers_in[] = { |
56 { ngx_string("Host"), offsetof(ngx_http_headers_in_t, host) }, | 57 { ngx_string("Host"), offsetof(ngx_http_headers_in_t, host) }, |
57 { ngx_string("Connection"), offsetof(ngx_http_headers_in_t, connection) }, | 58 { ngx_string("Connection"), offsetof(ngx_http_headers_in_t, connection) }, |
58 { ngx_string("If-Modified-Since"), | 59 { ngx_string("If-Modified-Since"), |
59 offsetof(ngx_http_headers_in_t, if_modified_since) }, | 60 offsetof(ngx_http_headers_in_t, if_modified_since) }, |
61 { ngx_string("Content-Length"), | |
62 offsetof(ngx_http_headers_in_t, content_length) }, | |
60 | 63 |
61 { ngx_string("User-Agent"), offsetof(ngx_http_headers_in_t, user_agent) }, | 64 { ngx_string("User-Agent"), offsetof(ngx_http_headers_in_t, user_agent) }, |
62 | 65 |
63 { ngx_null_string, 0 } | 66 { ngx_null_string, 0 } |
64 }; | 67 }; |
167 | 170 |
168 ctx = (ngx_http_conf_ctx_t *) c->ctx; | 171 ctx = (ngx_http_conf_ctx_t *) c->ctx; |
169 r->srv_conf = ctx->srv_conf; | 172 r->srv_conf = ctx->srv_conf; |
170 r->loc_conf = ctx->loc_conf; | 173 r->loc_conf = ctx->loc_conf; |
171 | 174 |
175 r->headers_in.content_length_n = -1; | |
172 r->headers_out.headers = ngx_create_table(r->pool, 10); | 176 r->headers_out.headers = ngx_create_table(r->pool, 10); |
173 r->headers_out.content_length = -1; | 177 r->headers_out.content_length = -1; |
174 r->headers_out.last_modified_time = -1; | 178 r->headers_out.last_modified_time = -1; |
175 | 179 |
176 rev->event_handler = ngx_http_process_request; | 180 rev->event_handler = ngx_http_process_request; |
529 return NGX_HTTP_BAD_REQUEST; | 533 return NGX_HTTP_BAD_REQUEST; |
530 } | 534 } |
531 r->headers_in.host_name_len = 0; | 535 r->headers_in.host_name_len = 0; |
532 } | 536 } |
533 | 537 |
538 if (r->headers_in.content_length) { | |
539 r->headers_in.content_length_n = | |
540 ngx_atoi(r->headers_in.content_length->value.data, | |
541 r->headers_in.content_length->value.len); | |
542 if (r->headers_in.content_length_n == NGX_ERROR) { | |
543 ngx_http_header_parse_error(r, | |
544 NGX_HTTP_PARSE_INVALID_CL_HEADER); | |
545 return NGX_HTTP_BAD_REQUEST; | |
546 } | |
547 } | |
548 | |
534 r->state_handler = NULL; | 549 r->state_handler = NULL; |
535 return NGX_OK; | 550 return NGX_OK; |
536 | 551 |
537 /* there was error while a header line parsing */ | 552 /* there was error while a header line parsing */ |
538 | 553 |
813 if (ev->timer_set) { | 828 if (ev->timer_set) { |
814 ngx_del_timer(ev); | 829 ngx_del_timer(ev); |
815 ev->timer_set = 0; | 830 ev->timer_set = 0; |
816 } | 831 } |
817 | 832 |
818 if (r->client_content_length) { | 833 if (r->headers_in.content_length_n) { |
819 ev->event_handler = ngx_http_read_discarded_body; | 834 ev->event_handler = ngx_http_read_discarded_body; |
820 /* if blocked - read */ | 835 /* if blocked - read */ |
821 /* else add timer */ | 836 /* else add timer */ |
822 } | 837 } |
823 | 838 |
850 ngx_test_null(r->discarded_buffer, | 865 ngx_test_null(r->discarded_buffer, |
851 ngx_palloc(r->pool, lcf->discarded_buffer_size), | 866 ngx_palloc(r->pool, lcf->discarded_buffer_size), |
852 NGX_ERROR); | 867 NGX_ERROR); |
853 } | 868 } |
854 | 869 |
855 size = r->client_content_length; | 870 size = r->headers_in.content_length_n; |
856 if (size > lcf->discarded_buffer_size) { | 871 if (size > lcf->discarded_buffer_size) { |
857 size = lcf->discarded_buffer_size; | 872 size = lcf->discarded_buffer_size; |
858 } | 873 } |
859 | 874 |
860 n = ngx_event_recv(c, r->discarded_buffer, size); | 875 n = ngx_event_recv(c, r->discarded_buffer, size); |
864 | 879 |
865 if (n == NGX_AGAIN) { | 880 if (n == NGX_AGAIN) { |
866 return NGX_OK; | 881 return NGX_OK; |
867 } | 882 } |
868 | 883 |
869 r->client_content_length -= n; | 884 r->headers_in.content_length_n -= n; |
870 /* XXX: what if r->client_content_length == 0 ? */ | 885 /* XXX: what if r->client_content_length == 0 ? */ |
871 return NGX_OK; | 886 return NGX_OK; |
872 } | 887 } |
873 | 888 |
874 | 889 |