Mercurial > hg > nginx
comparison src/http/ngx_http_parse.c @ 290:87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 16 Mar 2004 07:10:12 +0000 |
parents | 70e1c7d2b83d |
children | 117ccc7c4055 |
comparison
equal
deleted
inserted
replaced
289:0750faf8d7e3 | 290:87e73f067470 |
---|---|
3 #include <ngx_core.h> | 3 #include <ngx_core.h> |
4 #include <ngx_http.h> | 4 #include <ngx_http.h> |
5 | 5 |
6 ngx_int_t ngx_http_parse_request_line(ngx_http_request_t *r) | 6 ngx_int_t ngx_http_parse_request_line(ngx_http_request_t *r) |
7 { | 7 { |
8 char ch, *p; | 8 u_char ch, *p; |
9 enum { | 9 enum { |
10 sw_start = 0, | 10 sw_start = 0, |
11 sw_G, | 11 sw_G, |
12 sw_GE, | 12 sw_GE, |
13 sw_H, | 13 sw_H, |
419 } | 419 } |
420 | 420 |
421 | 421 |
422 ngx_int_t ngx_http_parse_header_line(ngx_http_request_t *r, ngx_hunk_t *h) | 422 ngx_int_t ngx_http_parse_header_line(ngx_http_request_t *r, ngx_hunk_t *h) |
423 { | 423 { |
424 char c, ch, *p; | 424 u_char c, ch, *p; |
425 enum { | 425 enum { |
426 sw_start = 0, | 426 sw_start = 0, |
427 sw_name, | 427 sw_name, |
428 sw_space_before_value, | 428 sw_space_before_value, |
429 sw_value, | 429 sw_value, |
456 break; | 456 break; |
457 default: | 457 default: |
458 state = sw_name; | 458 state = sw_name; |
459 r->header_name_start = p - 1; | 459 r->header_name_start = p - 1; |
460 | 460 |
461 c = ch | 0x20; | 461 c = (char) (ch | 0x20); |
462 if (c >= 'a' && c <= 'z') { | 462 if (c >= 'a' && c <= 'z') { |
463 break; | 463 break; |
464 } | 464 } |
465 | 465 |
466 if (ch == '-' || ch == '_' || ch == '~' || ch == '.') { | 466 if (ch == '-' || ch == '_' || ch == '~' || ch == '.') { |
476 } | 476 } |
477 break; | 477 break; |
478 | 478 |
479 /* header name */ | 479 /* header name */ |
480 case sw_name: | 480 case sw_name: |
481 c = ch | 0x20; | 481 c = (u_char) (ch | 0x20); |
482 if (c >= 'a' && c <= 'z') { | 482 if (c >= 'a' && c <= 'z') { |
483 break; | 483 break; |
484 } | 484 } |
485 | 485 |
486 if (ch == ':') { | 486 if (ch == ':') { |
621 } | 621 } |
622 | 622 |
623 | 623 |
624 ngx_int_t ngx_http_parse_complex_uri(ngx_http_request_t *r) | 624 ngx_int_t ngx_http_parse_complex_uri(ngx_http_request_t *r) |
625 { | 625 { |
626 char c, ch, decoded, *p, *u; | 626 u_char c, ch, decoded, *p, *u; |
627 enum { | 627 enum { |
628 sw_usual = 0, | 628 sw_usual = 0, |
629 sw_slash, | 629 sw_slash, |
630 sw_dot, | 630 sw_dot, |
631 sw_dot_dot, | 631 sw_dot_dot, |
776 break; | 776 break; |
777 #endif | 777 #endif |
778 | 778 |
779 case sw_quoted: | 779 case sw_quoted: |
780 if (ch >= '0' && ch <= '9') { | 780 if (ch >= '0' && ch <= '9') { |
781 decoded = ch - '0'; | 781 decoded = (char) (ch - '0'); |
782 state = sw_quoted_second; | 782 state = sw_quoted_second; |
783 ch = *p++; | 783 ch = *p++; |
784 break; | 784 break; |
785 } | 785 } |
786 | 786 |
787 c = ch | 0x20; | 787 c = (char) (ch | 0x20); |
788 if (c >= 'a' && c <= 'f') { | 788 if (c >= 'a' && c <= 'f') { |
789 decoded = c - 'a' + 10; | 789 decoded = (char) (c - 'a' + 10); |
790 state = sw_quoted_second; | 790 state = sw_quoted_second; |
791 ch = *p++; | 791 ch = *p++; |
792 break; | 792 break; |
793 } | 793 } |
794 | 794 |
795 return NGX_HTTP_PARSE_INVALID_REQUEST; | 795 return NGX_HTTP_PARSE_INVALID_REQUEST; |
796 | 796 |
797 case sw_quoted_second: | 797 case sw_quoted_second: |
798 if (ch >= '0' && ch <= '9') { | 798 if (ch >= '0' && ch <= '9') { |
799 ch = (decoded << 4) + ch - '0'; | 799 ch = (char) ((decoded << 4) + ch - '0'); |
800 if (ch == '%') { | 800 if (ch == '%') { |
801 state = sw_usual; | 801 state = sw_usual; |
802 *u++ = ch; | 802 *u++ = ch; |
803 ch = *p++; | 803 ch = *p++; |
804 break; | 804 break; |
805 } | 805 } |
806 state = quoted_state; | 806 state = quoted_state; |
807 break; | 807 break; |
808 } | 808 } |
809 | 809 |
810 c = ch | 0x20; | 810 c = (char) (ch | 0x20); |
811 if (c >= 'a' && c <= 'f') { | 811 if (c >= 'a' && c <= 'f') { |
812 ch = (decoded << 4) + c - 'a' + 10; | 812 ch = (char) ((decoded << 4) + c - 'a' + 10); |
813 if (ch == '%') { | 813 if (ch == '%') { |
814 state = sw_usual; | 814 state = sw_usual; |
815 *u++ = ch; | 815 *u++ = ch; |
816 ch = *p++; | 816 ch = *p++; |
817 break; | 817 break; |