Mercurial > hg > nginx-quic
annotate src/http/ngx_http_parse.c @ 7802:0cb942c1c1aa
Auth basic: explicitly zero out password buffer.
author | Ruslan Ermilov <ru@nginx.com> |
---|---|
date | Fri, 13 Mar 2020 02:12:10 +0300 |
parents | 8f55cb5c7e79 |
children | 38c0898b6df7 8989fbd2f89a |
rev | line source |
---|---|
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
1 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
4412 | 4 * Copyright (C) Nginx, Inc. |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
5 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
432
diff
changeset
|
6 |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_config.h> |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
9 #include <ngx_core.h> |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 #include <ngx_http.h> |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
12 |
831 | 13 static uint32_t usual[] = { |
827 | 14 0xffffdbfe, /* 1111 1111 1111 1111 1101 1011 1111 1110 */ |
823
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
15 |
827 | 16 /* ?>=< ;:98 7654 3210 /.-, +*)( '&%$ #"! */ |
17 0x7fff37d6, /* 0111 1111 1111 1111 0011 0111 1101 0110 */ | |
18 | |
19 /* _^]\ [ZYX WVUT SRQP ONML KJIH GFED CBA@ */ | |
830
51b08975dfa3
treat '\' as special character in win32 only
Igor Sysoev <igor@sysoev.ru>
parents:
827
diff
changeset
|
20 #if (NGX_WIN32) |
827 | 21 0xefffffff, /* 1110 1111 1111 1111 1111 1111 1111 1111 */ |
830
51b08975dfa3
treat '\' as special character in win32 only
Igor Sysoev <igor@sysoev.ru>
parents:
827
diff
changeset
|
22 #else |
51b08975dfa3
treat '\' as special character in win32 only
Igor Sysoev <igor@sysoev.ru>
parents:
827
diff
changeset
|
23 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ |
51b08975dfa3
treat '\' as special character in win32 only
Igor Sysoev <igor@sysoev.ru>
parents:
827
diff
changeset
|
24 #endif |
823
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
25 |
827 | 26 /* ~}| {zyx wvut srqp onml kjih gfed cba` */ |
27 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ | |
823
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
28 |
827 | 29 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ |
30 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ | |
31 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ | |
32 0xffffffff /* 1111 1111 1111 1111 1111 1111 1111 1111 */ | |
33 }; | |
823
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
34 |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
35 |
1196
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
36 #if (NGX_HAVE_LITTLE_ENDIAN && NGX_HAVE_NONALIGNED) |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
37 |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
38 #define ngx_str3_cmp(m, c0, c1, c2, c3) \ |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
39 *(uint32_t *) m == ((c3 << 24) | (c2 << 16) | (c1 << 8) | c0) |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
40 |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
41 #define ngx_str3Ocmp(m, c0, c1, c2, c3) \ |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
42 *(uint32_t *) m == ((c3 << 24) | (c2 << 16) | (c1 << 8) | c0) |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
43 |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
44 #define ngx_str4cmp(m, c0, c1, c2, c3) \ |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
45 *(uint32_t *) m == ((c3 << 24) | (c2 << 16) | (c1 << 8) | c0) |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
46 |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
47 #define ngx_str5cmp(m, c0, c1, c2, c3, c4) \ |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
48 *(uint32_t *) m == ((c3 << 24) | (c2 << 16) | (c1 << 8) | c0) \ |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
49 && m[4] == c4 |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
50 |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
51 #define ngx_str6cmp(m, c0, c1, c2, c3, c4, c5) \ |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
52 *(uint32_t *) m == ((c3 << 24) | (c2 << 16) | (c1 << 8) | c0) \ |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
53 && (((uint32_t *) m)[1] & 0xffff) == ((c5 << 8) | c4) |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
54 |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
55 #define ngx_str7_cmp(m, c0, c1, c2, c3, c4, c5, c6, c7) \ |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
56 *(uint32_t *) m == ((c3 << 24) | (c2 << 16) | (c1 << 8) | c0) \ |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
57 && ((uint32_t *) m)[1] == ((c7 << 24) | (c6 << 16) | (c5 << 8) | c4) |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
58 |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
59 #define ngx_str8cmp(m, c0, c1, c2, c3, c4, c5, c6, c7) \ |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
60 *(uint32_t *) m == ((c3 << 24) | (c2 << 16) | (c1 << 8) | c0) \ |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
61 && ((uint32_t *) m)[1] == ((c7 << 24) | (c6 << 16) | (c5 << 8) | c4) |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
62 |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
63 #define ngx_str9cmp(m, c0, c1, c2, c3, c4, c5, c6, c7, c8) \ |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
64 *(uint32_t *) m == ((c3 << 24) | (c2 << 16) | (c1 << 8) | c0) \ |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
65 && ((uint32_t *) m)[1] == ((c7 << 24) | (c6 << 16) | (c5 << 8) | c4) \ |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
66 && m[8] == c8 |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
67 |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
68 #else /* !(NGX_HAVE_LITTLE_ENDIAN && NGX_HAVE_NONALIGNED) */ |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
69 |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
70 #define ngx_str3_cmp(m, c0, c1, c2, c3) \ |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
71 m[0] == c0 && m[1] == c1 && m[2] == c2 |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
72 |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
73 #define ngx_str3Ocmp(m, c0, c1, c2, c3) \ |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
74 m[0] == c0 && m[2] == c2 && m[3] == c3 |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
75 |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
76 #define ngx_str4cmp(m, c0, c1, c2, c3) \ |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
77 m[0] == c0 && m[1] == c1 && m[2] == c2 && m[3] == c3 |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
78 |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
79 #define ngx_str5cmp(m, c0, c1, c2, c3, c4) \ |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
80 m[0] == c0 && m[1] == c1 && m[2] == c2 && m[3] == c3 && m[4] == c4 |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
81 |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
82 #define ngx_str6cmp(m, c0, c1, c2, c3, c4, c5) \ |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
83 m[0] == c0 && m[1] == c1 && m[2] == c2 && m[3] == c3 \ |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
84 && m[4] == c4 && m[5] == c5 |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
85 |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
86 #define ngx_str7_cmp(m, c0, c1, c2, c3, c4, c5, c6, c7) \ |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
87 m[0] == c0 && m[1] == c1 && m[2] == c2 && m[3] == c3 \ |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
88 && m[4] == c4 && m[5] == c5 && m[6] == c6 |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
89 |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
90 #define ngx_str8cmp(m, c0, c1, c2, c3, c4, c5, c6, c7) \ |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
91 m[0] == c0 && m[1] == c1 && m[2] == c2 && m[3] == c3 \ |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
92 && m[4] == c4 && m[5] == c5 && m[6] == c6 && m[7] == c7 |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
93 |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
94 #define ngx_str9cmp(m, c0, c1, c2, c3, c4, c5, c6, c7, c8) \ |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
95 m[0] == c0 && m[1] == c1 && m[2] == c2 && m[3] == c3 \ |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
96 && m[4] == c4 && m[5] == c5 && m[6] == c6 && m[7] == c7 && m[8] == c8 |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
97 |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
98 #endif |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
99 |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
100 |
649 | 101 /* gcc, icc, msvc and others compile these switches as an jump table */ |
102 | |
509 | 103 ngx_int_t |
104 ngx_http_parse_request_line(ngx_http_request_t *r, ngx_buf_t *b) | |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
105 { |
507 | 106 u_char c, ch, *p, *m; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
107 enum { |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
108 sw_start = 0, |
314
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
109 sw_method, |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
110 sw_spaces_before_uri, |
314
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
111 sw_schema, |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
112 sw_schema_slash, |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
113 sw_schema_slash_slash, |
4313
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
114 sw_host_start, |
314
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
115 sw_host, |
4313
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
116 sw_host_end, |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
117 sw_host_ip_literal, |
314
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
118 sw_port, |
3615 | 119 sw_host_http_09, |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
120 sw_after_slash_in_uri, |
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
121 sw_check_uri, |
3615 | 122 sw_check_uri_http_09, |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
123 sw_uri, |
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
124 sw_http_09, |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
125 sw_http_H, |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
126 sw_http_HT, |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
127 sw_http_HTT, |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
128 sw_http_HTTP, |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
129 sw_first_major_digit, |
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
130 sw_major_digit, |
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
131 sw_first_minor_digit, |
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
132 sw_minor_digit, |
1603
364587232429
compatibility with mget: space after HTTP/1.1
Igor Sysoev <igor@sysoev.ru>
parents:
1585
diff
changeset
|
133 sw_spaces_after_digit, |
479 | 134 sw_almost_done |
21
df7fb216a149
nginx-0.0.1-2002-12-04-19:29:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
18
diff
changeset
|
135 } state; |
df7fb216a149
nginx-0.0.1-2002-12-04-19:29:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
18
diff
changeset
|
136 |
df7fb216a149
nginx-0.0.1-2002-12-04-19:29:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
18
diff
changeset
|
137 state = r->state; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
138 |
479 | 139 for (p = b->pos; p < b->last; p++) { |
140 ch = *p; | |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
141 |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
142 switch (state) { |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
143 |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
144 /* HTTP methods: GET, HEAD, POST */ |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
145 case sw_start: |
479 | 146 r->request_start = p; |
65
4222c496acb3
nginx-0.0.1-2003-03-05-09:37:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
147 |
323
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
148 if (ch == CR || ch == LF) { |
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
149 break; |
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
150 } |
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
151 |
6732
57148b755320
Allowed '-' in method names.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6626
diff
changeset
|
152 if ((ch < 'A' || ch > 'Z') && ch != '_' && ch != '-') { |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
153 return NGX_HTTP_PARSE_INVALID_METHOD; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
154 } |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
155 |
314
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
156 state = sw_method; |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
157 break; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
158 |
314
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
159 case sw_method: |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
160 if (ch == ' ') { |
509 | 161 r->method_end = p - 1; |
314
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
162 m = r->request_start; |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
163 |
639 | 164 switch (p - m) { |
314
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
165 |
639 | 166 case 3: |
1196
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
167 if (ngx_str3_cmp(m, 'G', 'E', 'T', ' ')) { |
314
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
168 r->method = NGX_HTTP_GET; |
844 | 169 break; |
170 } | |
633 | 171 |
1196
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
172 if (ngx_str3_cmp(m, 'P', 'U', 'T', ' ')) { |
633 | 173 r->method = NGX_HTTP_PUT; |
844 | 174 break; |
314
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
175 } |
844 | 176 |
639 | 177 break; |
314
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
178 |
639 | 179 case 4: |
844 | 180 if (m[1] == 'O') { |
181 | |
1196
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
182 if (ngx_str3Ocmp(m, 'P', 'O', 'S', 'T')) { |
844 | 183 r->method = NGX_HTTP_POST; |
184 break; | |
185 } | |
186 | |
1196
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
187 if (ngx_str3Ocmp(m, 'C', 'O', 'P', 'Y')) { |
844 | 188 r->method = NGX_HTTP_COPY; |
189 break; | |
190 } | |
314
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
191 |
1196
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
192 if (ngx_str3Ocmp(m, 'M', 'O', 'V', 'E')) { |
844 | 193 r->method = NGX_HTTP_MOVE; |
194 break; | |
195 } | |
196 | |
1196
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
197 if (ngx_str3Ocmp(m, 'L', 'O', 'C', 'K')) { |
844 | 198 r->method = NGX_HTTP_LOCK; |
199 break; | |
200 } | |
201 | |
202 } else { | |
203 | |
1196
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
204 if (ngx_str4cmp(m, 'H', 'E', 'A', 'D')) { |
844 | 205 r->method = NGX_HTTP_HEAD; |
206 break; | |
207 } | |
314
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
208 } |
844 | 209 |
639 | 210 break; |
633 | 211 |
639 | 212 case 5: |
1196
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
213 if (ngx_str5cmp(m, 'M', 'K', 'C', 'O', 'L')) { |
637 | 214 r->method = NGX_HTTP_MKCOL; |
5328
17291cb8c76e
Minor ngx_http_parse_request_line() optimization.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5256
diff
changeset
|
215 break; |
637 | 216 } |
844 | 217 |
3613 | 218 if (ngx_str5cmp(m, 'P', 'A', 'T', 'C', 'H')) { |
219 r->method = NGX_HTTP_PATCH; | |
5328
17291cb8c76e
Minor ngx_http_parse_request_line() optimization.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5256
diff
changeset
|
220 break; |
3613 | 221 } |
222 | |
1196
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
223 if (ngx_str5cmp(m, 'T', 'R', 'A', 'C', 'E')) { |
1151 | 224 r->method = NGX_HTTP_TRACE; |
5328
17291cb8c76e
Minor ngx_http_parse_request_line() optimization.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5256
diff
changeset
|
225 break; |
1151 | 226 } |
227 | |
639 | 228 break; |
637 | 229 |
639 | 230 case 6: |
1196
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
231 if (ngx_str6cmp(m, 'D', 'E', 'L', 'E', 'T', 'E')) { |
633 | 232 r->method = NGX_HTTP_DELETE; |
844 | 233 break; |
633 | 234 } |
844 | 235 |
1196
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
236 if (ngx_str6cmp(m, 'U', 'N', 'L', 'O', 'C', 'K')) { |
844 | 237 r->method = NGX_HTTP_UNLOCK; |
238 break; | |
239 } | |
240 | |
241 break; | |
242 | |
243 case 7: | |
1196
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
244 if (ngx_str7_cmp(m, 'O', 'P', 'T', 'I', 'O', 'N', 'S', ' ')) |
844 | 245 { |
246 r->method = NGX_HTTP_OPTIONS; | |
247 } | |
248 | |
249 break; | |
250 | |
251 case 8: | |
1196
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
252 if (ngx_str8cmp(m, 'P', 'R', 'O', 'P', 'F', 'I', 'N', 'D')) |
844 | 253 { |
254 r->method = NGX_HTTP_PROPFIND; | |
255 } | |
256 | |
257 break; | |
258 | |
259 case 9: | |
1196
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
260 if (ngx_str9cmp(m, |
67077918b965
optimize HTTP method parsing for i386 and amd64
Igor Sysoev <igor@sysoev.ru>
parents:
1151
diff
changeset
|
261 'P', 'R', 'O', 'P', 'P', 'A', 'T', 'C', 'H')) |
844 | 262 { |
263 r->method = NGX_HTTP_PROPPATCH; | |
264 } | |
265 | |
639 | 266 break; |
314
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
267 } |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
268 |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
269 state = sw_spaces_before_uri; |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
270 break; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
271 } |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
272 |
6732
57148b755320
Allowed '-' in method names.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6626
diff
changeset
|
273 if ((ch < 'A' || ch > 'Z') && ch != '_' && ch != '-') { |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
274 return NGX_HTTP_PARSE_INVALID_METHOD; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
275 } |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
276 |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
277 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
278 |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
279 /* space* before URI */ |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
280 case sw_spaces_before_uri: |
507 | 281 |
3642 | 282 if (ch == '/') { |
822
a908ba404078
handle the most frequent case first
Igor Sysoev <igor@sysoev.ru>
parents:
821
diff
changeset
|
283 r->uri_start = p; |
a908ba404078
handle the most frequent case first
Igor Sysoev <igor@sysoev.ru>
parents:
821
diff
changeset
|
284 state = sw_after_slash_in_uri; |
a908ba404078
handle the most frequent case first
Igor Sysoev <igor@sysoev.ru>
parents:
821
diff
changeset
|
285 break; |
a908ba404078
handle the most frequent case first
Igor Sysoev <igor@sysoev.ru>
parents:
821
diff
changeset
|
286 } |
a908ba404078
handle the most frequent case first
Igor Sysoev <igor@sysoev.ru>
parents:
821
diff
changeset
|
287 |
507 | 288 c = (u_char) (ch | 0x20); |
521 | 289 if (c >= 'a' && c <= 'z') { |
489 | 290 r->schema_start = p; |
291 state = sw_schema; | |
292 break; | |
293 } | |
294 | |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
295 switch (ch) { |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
296 case ' ': |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
297 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
298 default: |
314
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
299 return NGX_HTTP_PARSE_INVALID_REQUEST; |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
300 } |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
301 break; |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
302 |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
303 case sw_schema: |
507 | 304 |
305 c = (u_char) (ch | 0x20); | |
521 | 306 if (c >= 'a' && c <= 'z') { |
489 | 307 break; |
308 } | |
309 | |
7292
f9661f56c717
Allowed digits, '+', '-', and '.' in scheme names as per RFC 3986.
Ruslan Ermilov <ru@nginx.com>
parents:
7067
diff
changeset
|
310 if ((ch >= '0' && ch <= '9') || ch == '+' || ch == '-' || ch == '.') |
f9661f56c717
Allowed digits, '+', '-', and '.' in scheme names as per RFC 3986.
Ruslan Ermilov <ru@nginx.com>
parents:
7067
diff
changeset
|
311 { |
f9661f56c717
Allowed digits, '+', '-', and '.' in scheme names as per RFC 3986.
Ruslan Ermilov <ru@nginx.com>
parents:
7067
diff
changeset
|
312 break; |
f9661f56c717
Allowed digits, '+', '-', and '.' in scheme names as per RFC 3986.
Ruslan Ermilov <ru@nginx.com>
parents:
7067
diff
changeset
|
313 } |
f9661f56c717
Allowed digits, '+', '-', and '.' in scheme names as per RFC 3986.
Ruslan Ermilov <ru@nginx.com>
parents:
7067
diff
changeset
|
314 |
314
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
315 switch (ch) { |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
316 case ':': |
479 | 317 r->schema_end = p; |
314
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
318 state = sw_schema_slash; |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
319 break; |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
320 default: |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
321 return NGX_HTTP_PARSE_INVALID_REQUEST; |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
322 } |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
323 break; |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
324 |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
325 case sw_schema_slash: |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
326 switch (ch) { |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
327 case '/': |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
328 state = sw_schema_slash_slash; |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
329 break; |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
330 default: |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
331 return NGX_HTTP_PARSE_INVALID_REQUEST; |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
332 } |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
333 break; |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
334 |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
335 case sw_schema_slash_slash: |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
336 switch (ch) { |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
337 case '/': |
4313
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
338 state = sw_host_start; |
314
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
339 break; |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
340 default: |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
341 return NGX_HTTP_PARSE_INVALID_REQUEST; |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
342 } |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
343 break; |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
344 |
4313
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
345 case sw_host_start: |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
346 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
347 r->host_start = p; |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
348 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
349 if (ch == '[') { |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
350 state = sw_host_ip_literal; |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
351 break; |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
352 } |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
353 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
354 state = sw_host; |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
355 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
356 /* fall through */ |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
357 |
314
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
358 case sw_host: |
507 | 359 |
360 c = (u_char) (ch | 0x20); | |
521 | 361 if (c >= 'a' && c <= 'z') { |
507 | 362 break; |
363 } | |
364 | |
832 | 365 if ((ch >= '0' && ch <= '9') || ch == '.' || ch == '-') { |
489 | 366 break; |
367 } | |
368 | |
4313
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
369 /* fall through */ |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
370 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
371 case sw_host_end: |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
372 |
1584
25427a0e9559
allow full URL without URI part: "GET http://host HTTP/1.0"
Igor Sysoev <igor@sysoev.ru>
parents:
1196
diff
changeset
|
373 r->host_end = p; |
25427a0e9559
allow full URL without URI part: "GET http://host HTTP/1.0"
Igor Sysoev <igor@sysoev.ru>
parents:
1196
diff
changeset
|
374 |
314
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
375 switch (ch) { |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
376 case ':': |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
377 state = sw_port; |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
378 break; |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
379 case '/': |
479 | 380 r->uri_start = p; |
314
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
381 state = sw_after_slash_in_uri; |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
382 break; |
1584
25427a0e9559
allow full URL without URI part: "GET http://host HTTP/1.0"
Igor Sysoev <igor@sysoev.ru>
parents:
1196
diff
changeset
|
383 case ' ': |
25427a0e9559
allow full URL without URI part: "GET http://host HTTP/1.0"
Igor Sysoev <igor@sysoev.ru>
parents:
1196
diff
changeset
|
384 /* |
25427a0e9559
allow full URL without URI part: "GET http://host HTTP/1.0"
Igor Sysoev <igor@sysoev.ru>
parents:
1196
diff
changeset
|
385 * use single "/" from request line to preserve pointers, |
25427a0e9559
allow full URL without URI part: "GET http://host HTTP/1.0"
Igor Sysoev <igor@sysoev.ru>
parents:
1196
diff
changeset
|
386 * if request line will be copied to large client buffer |
25427a0e9559
allow full URL without URI part: "GET http://host HTTP/1.0"
Igor Sysoev <igor@sysoev.ru>
parents:
1196
diff
changeset
|
387 */ |
25427a0e9559
allow full URL without URI part: "GET http://host HTTP/1.0"
Igor Sysoev <igor@sysoev.ru>
parents:
1196
diff
changeset
|
388 r->uri_start = r->schema_end + 1; |
25427a0e9559
allow full URL without URI part: "GET http://host HTTP/1.0"
Igor Sysoev <igor@sysoev.ru>
parents:
1196
diff
changeset
|
389 r->uri_end = r->schema_end + 2; |
3615 | 390 state = sw_host_http_09; |
1584
25427a0e9559
allow full URL without URI part: "GET http://host HTTP/1.0"
Igor Sysoev <igor@sysoev.ru>
parents:
1196
diff
changeset
|
391 break; |
314
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
392 default: |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
393 return NGX_HTTP_PARSE_INVALID_REQUEST; |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
394 } |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
395 break; |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
396 |
4313
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
397 case sw_host_ip_literal: |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
398 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
399 if (ch >= '0' && ch <= '9') { |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
400 break; |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
401 } |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
402 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
403 c = (u_char) (ch | 0x20); |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
404 if (c >= 'a' && c <= 'z') { |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
405 break; |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
406 } |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
407 |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
408 switch (ch) { |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
409 case ':': |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
410 break; |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
411 case ']': |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
412 state = sw_host_end; |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
413 break; |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
414 case '-': |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
415 case '.': |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
416 case '_': |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
417 case '~': |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
418 /* unreserved */ |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
419 break; |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
420 case '!': |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
421 case '$': |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
422 case '&': |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
423 case '\'': |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
424 case '(': |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
425 case ')': |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
426 case '*': |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
427 case '+': |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
428 case ',': |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
429 case ';': |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
430 case '=': |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
431 /* sub-delims */ |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
432 break; |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
433 default: |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
434 return NGX_HTTP_PARSE_INVALID_REQUEST; |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
435 } |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
436 break; |
e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Valentin Bartenev <vbart@nginx.com>
parents:
4125
diff
changeset
|
437 |
314
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
438 case sw_port: |
489 | 439 if (ch >= '0' && ch <= '9') { |
440 break; | |
441 } | |
442 | |
314
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
443 switch (ch) { |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
444 case '/': |
479 | 445 r->port_end = p; |
446 r->uri_start = p; | |
314
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
447 state = sw_after_slash_in_uri; |
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
448 break; |
1584
25427a0e9559
allow full URL without URI part: "GET http://host HTTP/1.0"
Igor Sysoev <igor@sysoev.ru>
parents:
1196
diff
changeset
|
449 case ' ': |
25427a0e9559
allow full URL without URI part: "GET http://host HTTP/1.0"
Igor Sysoev <igor@sysoev.ru>
parents:
1196
diff
changeset
|
450 r->port_end = p; |
25427a0e9559
allow full URL without URI part: "GET http://host HTTP/1.0"
Igor Sysoev <igor@sysoev.ru>
parents:
1196
diff
changeset
|
451 /* |
25427a0e9559
allow full URL without URI part: "GET http://host HTTP/1.0"
Igor Sysoev <igor@sysoev.ru>
parents:
1196
diff
changeset
|
452 * use single "/" from request line to preserve pointers, |
25427a0e9559
allow full URL without URI part: "GET http://host HTTP/1.0"
Igor Sysoev <igor@sysoev.ru>
parents:
1196
diff
changeset
|
453 * if request line will be copied to large client buffer |
25427a0e9559
allow full URL without URI part: "GET http://host HTTP/1.0"
Igor Sysoev <igor@sysoev.ru>
parents:
1196
diff
changeset
|
454 */ |
25427a0e9559
allow full URL without URI part: "GET http://host HTTP/1.0"
Igor Sysoev <igor@sysoev.ru>
parents:
1196
diff
changeset
|
455 r->uri_start = r->schema_end + 1; |
25427a0e9559
allow full URL without URI part: "GET http://host HTTP/1.0"
Igor Sysoev <igor@sysoev.ru>
parents:
1196
diff
changeset
|
456 r->uri_end = r->schema_end + 2; |
3615 | 457 state = sw_host_http_09; |
1584
25427a0e9559
allow full URL without URI part: "GET http://host HTTP/1.0"
Igor Sysoev <igor@sysoev.ru>
parents:
1196
diff
changeset
|
458 break; |
314
d71c87d11b16
nginx-0.0.3-2004-04-14-09:57:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
459 default: |
489 | 460 return NGX_HTTP_PARSE_INVALID_REQUEST; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
461 } |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
462 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
463 |
3615 | 464 /* space+ after "http://host[:port] " */ |
465 case sw_host_http_09: | |
466 switch (ch) { | |
467 case ' ': | |
468 break; | |
469 case CR: | |
470 r->http_minor = 9; | |
471 state = sw_almost_done; | |
472 break; | |
473 case LF: | |
474 r->http_minor = 9; | |
475 goto done; | |
476 case 'H': | |
477 r->http_protocol.data = p; | |
478 state = sw_http_H; | |
479 break; | |
480 default: | |
481 return NGX_HTTP_PARSE_INVALID_REQUEST; | |
482 } | |
483 break; | |
484 | |
485 | |
461 | 486 /* check "/.", "//", "%", and "\" (Win32) in URI */ |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
487 case sw_after_slash_in_uri: |
489 | 488 |
6626
b3682580c1bd
Avoid left-shifting integers into the sign bit, which is undefined.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6543
diff
changeset
|
489 if (usual[ch >> 5] & (1U << (ch & 0x1f))) { |
489 | 490 state = sw_check_uri; |
491 break; | |
492 } | |
493 | |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
494 switch (ch) { |
489 | 495 case ' ': |
496 r->uri_end = p; | |
3615 | 497 state = sw_check_uri_http_09; |
489 | 498 break; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
499 case CR: |
479 | 500 r->uri_end = p; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
501 r->http_minor = 9; |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
502 state = sw_almost_done; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
503 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
504 case LF: |
479 | 505 r->uri_end = p; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
506 r->http_minor = 9; |
479 | 507 goto done; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
508 case '.': |
452 | 509 r->complex_uri = 1; |
510 state = sw_uri; | |
511 break; | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
512 case '%': |
452 | 513 r->quoted_uri = 1; |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
514 state = sw_uri; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
515 break; |
489 | 516 case '/': |
517 r->complex_uri = 1; | |
518 state = sw_uri; | |
519 break; | |
461 | 520 #if (NGX_WIN32) |
521 case '\\': | |
522 r->complex_uri = 1; | |
489 | 523 state = sw_uri; |
461 | 524 break; |
525 #endif | |
489 | 526 case '?': |
527 r->args_start = p + 1; | |
528 state = sw_uri; | |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
529 break; |
820 | 530 case '#': |
531 r->complex_uri = 1; | |
532 state = sw_uri; | |
533 break; | |
485 | 534 case '+': |
535 r->plus_in_uri = 1; | |
536 break; | |
489 | 537 case '\0': |
3527 | 538 return NGX_HTTP_PARSE_INVALID_REQUEST; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
539 default: |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
540 state = sw_check_uri; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
541 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
542 } |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
543 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
544 |
461 | 545 /* check "/", "%" and "\" (Win32) in URI */ |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
546 case sw_check_uri: |
489 | 547 |
6626
b3682580c1bd
Avoid left-shifting integers into the sign bit, which is undefined.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6543
diff
changeset
|
548 if (usual[ch >> 5] & (1U << (ch & 0x1f))) { |
489 | 549 break; |
550 } | |
551 | |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
552 switch (ch) { |
489 | 553 case '/': |
4674
5d86ab8f2340
Win32: normalization of trailing dot inside uri.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
554 #if (NGX_WIN32) |
5d86ab8f2340
Win32: normalization of trailing dot inside uri.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
555 if (r->uri_ext == p) { |
5d86ab8f2340
Win32: normalization of trailing dot inside uri.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
556 r->complex_uri = 1; |
5d86ab8f2340
Win32: normalization of trailing dot inside uri.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
557 state = sw_uri; |
5d86ab8f2340
Win32: normalization of trailing dot inside uri.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
558 break; |
5d86ab8f2340
Win32: normalization of trailing dot inside uri.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
559 } |
5d86ab8f2340
Win32: normalization of trailing dot inside uri.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
560 #endif |
489 | 561 r->uri_ext = NULL; |
562 state = sw_after_slash_in_uri; | |
563 break; | |
564 case '.': | |
565 r->uri_ext = p + 1; | |
566 break; | |
567 case ' ': | |
568 r->uri_end = p; | |
3615 | 569 state = sw_check_uri_http_09; |
489 | 570 break; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
571 case CR: |
479 | 572 r->uri_end = p; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
573 r->http_minor = 9; |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
574 state = sw_almost_done; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
575 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
576 case LF: |
479 | 577 r->uri_end = p; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
578 r->http_minor = 9; |
479 | 579 goto done; |
461 | 580 #if (NGX_WIN32) |
581 case '\\': | |
582 r->complex_uri = 1; | |
583 state = sw_after_slash_in_uri; | |
584 break; | |
585 #endif | |
489 | 586 case '%': |
587 r->quoted_uri = 1; | |
588 state = sw_uri; | |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
589 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
590 case '?': |
479 | 591 r->args_start = p + 1; |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
592 state = sw_uri; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
593 break; |
820 | 594 case '#': |
595 r->complex_uri = 1; | |
596 state = sw_uri; | |
597 break; | |
657 | 598 case '+': |
599 r->plus_in_uri = 1; | |
600 break; | |
489 | 601 case '\0': |
3527 | 602 return NGX_HTTP_PARSE_INVALID_REQUEST; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
603 } |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
604 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
605 |
3615 | 606 /* space+ after URI */ |
607 case sw_check_uri_http_09: | |
608 switch (ch) { | |
609 case ' ': | |
610 break; | |
611 case CR: | |
612 r->http_minor = 9; | |
613 state = sw_almost_done; | |
614 break; | |
615 case LF: | |
616 r->http_minor = 9; | |
617 goto done; | |
618 case 'H': | |
619 r->http_protocol.data = p; | |
620 state = sw_http_H; | |
621 break; | |
622 default: | |
623 r->space_in_uri = 1; | |
624 state = sw_check_uri; | |
5442
63f960bbc52f
Proper backtracking after space in a request line.
Ruslan Ermilov <ru@nginx.com>
parents:
5328
diff
changeset
|
625 p--; |
3615 | 626 break; |
627 } | |
628 break; | |
629 | |
630 | |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
631 /* URI */ |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
632 case sw_uri: |
823
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
633 |
6626
b3682580c1bd
Avoid left-shifting integers into the sign bit, which is undefined.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6543
diff
changeset
|
634 if (usual[ch >> 5] & (1U << (ch & 0x1f))) { |
823
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
635 break; |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
636 } |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
637 |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
638 switch (ch) { |
489 | 639 case ' ': |
640 r->uri_end = p; | |
641 state = sw_http_09; | |
642 break; | |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
643 case CR: |
479 | 644 r->uri_end = p; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
645 r->http_minor = 9; |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
646 state = sw_almost_done; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
647 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
648 case LF: |
479 | 649 r->uri_end = p; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
650 r->http_minor = 9; |
479 | 651 goto done; |
820 | 652 case '#': |
653 r->complex_uri = 1; | |
654 break; | |
489 | 655 case '\0': |
3527 | 656 return NGX_HTTP_PARSE_INVALID_REQUEST; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
657 } |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
658 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
659 |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
660 /* space+ after URI */ |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
661 case sw_http_09: |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
662 switch (ch) { |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
663 case ' ': |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
664 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
665 case CR: |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
666 r->http_minor = 9; |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
667 state = sw_almost_done; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
668 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
669 case LF: |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
670 r->http_minor = 9; |
479 | 671 goto done; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
672 case 'H': |
479 | 673 r->http_protocol.data = p; |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
674 state = sw_http_H; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
675 break; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
676 default: |
3615 | 677 r->space_in_uri = 1; |
678 state = sw_uri; | |
5442
63f960bbc52f
Proper backtracking after space in a request line.
Ruslan Ermilov <ru@nginx.com>
parents:
5328
diff
changeset
|
679 p--; |
3615 | 680 break; |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
681 } |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
682 break; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
683 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
684 case sw_http_H: |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
685 switch (ch) { |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
686 case 'T': |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
687 state = sw_http_HT; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
688 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
689 default: |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
9
diff
changeset
|
690 return NGX_HTTP_PARSE_INVALID_REQUEST; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
691 } |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
692 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
693 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
694 case sw_http_HT: |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
695 switch (ch) { |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
696 case 'T': |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
697 state = sw_http_HTT; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
698 break; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
699 default: |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
9
diff
changeset
|
700 return NGX_HTTP_PARSE_INVALID_REQUEST; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
701 } |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
702 break; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
703 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
704 case sw_http_HTT: |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
705 switch (ch) { |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
706 case 'P': |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
707 state = sw_http_HTTP; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
708 break; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
709 default: |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
710 return NGX_HTTP_PARSE_INVALID_REQUEST; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
711 } |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
712 break; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
713 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
714 case sw_http_HTTP: |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
715 switch (ch) { |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
716 case '/': |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
717 state = sw_first_major_digit; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
718 break; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
719 default: |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
720 return NGX_HTTP_PARSE_INVALID_REQUEST; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
721 } |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
722 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
723 |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
724 /* first digit of major HTTP version */ |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
725 case sw_first_major_digit: |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
726 if (ch < '1' || ch > '9') { |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
9
diff
changeset
|
727 return NGX_HTTP_PARSE_INVALID_REQUEST; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
728 } |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
729 |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
730 r->http_major = ch - '0'; |
6993
8801ff7d58e1
Don't pretend we support HTTP major versions >1 as HTTP/1.1.
Ruslan Ermilov <ru@nginx.com>
parents:
6732
diff
changeset
|
731 |
8801ff7d58e1
Don't pretend we support HTTP major versions >1 as HTTP/1.1.
Ruslan Ermilov <ru@nginx.com>
parents:
6732
diff
changeset
|
732 if (r->http_major > 1) { |
8801ff7d58e1
Don't pretend we support HTTP major versions >1 as HTTP/1.1.
Ruslan Ermilov <ru@nginx.com>
parents:
6732
diff
changeset
|
733 return NGX_HTTP_PARSE_INVALID_VERSION; |
8801ff7d58e1
Don't pretend we support HTTP major versions >1 as HTTP/1.1.
Ruslan Ermilov <ru@nginx.com>
parents:
6732
diff
changeset
|
734 } |
8801ff7d58e1
Don't pretend we support HTTP major versions >1 as HTTP/1.1.
Ruslan Ermilov <ru@nginx.com>
parents:
6732
diff
changeset
|
735 |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
736 state = sw_major_digit; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
737 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
738 |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
739 /* major HTTP version or dot */ |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
740 case sw_major_digit: |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
741 if (ch == '.') { |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
742 state = sw_first_minor_digit; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
743 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
744 } |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
745 |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
746 if (ch < '0' || ch > '9') { |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
9
diff
changeset
|
747 return NGX_HTTP_PARSE_INVALID_REQUEST; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
748 } |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
749 |
7067
e3723f2a11b7
Parenthesized ASCII-related calculations.
Valentin Bartenev <vbart@nginx.com>
parents:
6994
diff
changeset
|
750 r->http_major = r->http_major * 10 + (ch - '0'); |
6993
8801ff7d58e1
Don't pretend we support HTTP major versions >1 as HTTP/1.1.
Ruslan Ermilov <ru@nginx.com>
parents:
6732
diff
changeset
|
751 |
8801ff7d58e1
Don't pretend we support HTTP major versions >1 as HTTP/1.1.
Ruslan Ermilov <ru@nginx.com>
parents:
6732
diff
changeset
|
752 if (r->http_major > 1) { |
8801ff7d58e1
Don't pretend we support HTTP major versions >1 as HTTP/1.1.
Ruslan Ermilov <ru@nginx.com>
parents:
6732
diff
changeset
|
753 return NGX_HTTP_PARSE_INVALID_VERSION; |
6543
302ff40c9bc9
Added overflow checks for version numbers (ticket #762).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6014
diff
changeset
|
754 } |
302ff40c9bc9
Added overflow checks for version numbers (ticket #762).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6014
diff
changeset
|
755 |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
756 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
757 |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
758 /* first digit of minor HTTP version */ |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
759 case sw_first_minor_digit: |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
760 if (ch < '0' || ch > '9') { |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
9
diff
changeset
|
761 return NGX_HTTP_PARSE_INVALID_REQUEST; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
762 } |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
763 |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
764 r->http_minor = ch - '0'; |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
765 state = sw_minor_digit; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
766 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
767 |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
768 /* minor HTTP version or end of request line */ |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
769 case sw_minor_digit: |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
770 if (ch == CR) { |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
771 state = sw_almost_done; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
772 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
773 } |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
774 |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
775 if (ch == LF) { |
479 | 776 goto done; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
777 } |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
778 |
1603
364587232429
compatibility with mget: space after HTTP/1.1
Igor Sysoev <igor@sysoev.ru>
parents:
1585
diff
changeset
|
779 if (ch == ' ') { |
364587232429
compatibility with mget: space after HTTP/1.1
Igor Sysoev <igor@sysoev.ru>
parents:
1585
diff
changeset
|
780 state = sw_spaces_after_digit; |
364587232429
compatibility with mget: space after HTTP/1.1
Igor Sysoev <igor@sysoev.ru>
parents:
1585
diff
changeset
|
781 break; |
364587232429
compatibility with mget: space after HTTP/1.1
Igor Sysoev <igor@sysoev.ru>
parents:
1585
diff
changeset
|
782 } |
364587232429
compatibility with mget: space after HTTP/1.1
Igor Sysoev <igor@sysoev.ru>
parents:
1585
diff
changeset
|
783 |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
784 if (ch < '0' || ch > '9') { |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
9
diff
changeset
|
785 return NGX_HTTP_PARSE_INVALID_REQUEST; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
786 } |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
787 |
6543
302ff40c9bc9
Added overflow checks for version numbers (ticket #762).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6014
diff
changeset
|
788 if (r->http_minor > 99) { |
302ff40c9bc9
Added overflow checks for version numbers (ticket #762).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6014
diff
changeset
|
789 return NGX_HTTP_PARSE_INVALID_REQUEST; |
302ff40c9bc9
Added overflow checks for version numbers (ticket #762).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6014
diff
changeset
|
790 } |
302ff40c9bc9
Added overflow checks for version numbers (ticket #762).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6014
diff
changeset
|
791 |
7067
e3723f2a11b7
Parenthesized ASCII-related calculations.
Valentin Bartenev <vbart@nginx.com>
parents:
6994
diff
changeset
|
792 r->http_minor = r->http_minor * 10 + (ch - '0'); |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
793 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
794 |
1603
364587232429
compatibility with mget: space after HTTP/1.1
Igor Sysoev <igor@sysoev.ru>
parents:
1585
diff
changeset
|
795 case sw_spaces_after_digit: |
364587232429
compatibility with mget: space after HTTP/1.1
Igor Sysoev <igor@sysoev.ru>
parents:
1585
diff
changeset
|
796 switch (ch) { |
364587232429
compatibility with mget: space after HTTP/1.1
Igor Sysoev <igor@sysoev.ru>
parents:
1585
diff
changeset
|
797 case ' ': |
364587232429
compatibility with mget: space after HTTP/1.1
Igor Sysoev <igor@sysoev.ru>
parents:
1585
diff
changeset
|
798 break; |
364587232429
compatibility with mget: space after HTTP/1.1
Igor Sysoev <igor@sysoev.ru>
parents:
1585
diff
changeset
|
799 case CR: |
364587232429
compatibility with mget: space after HTTP/1.1
Igor Sysoev <igor@sysoev.ru>
parents:
1585
diff
changeset
|
800 state = sw_almost_done; |
364587232429
compatibility with mget: space after HTTP/1.1
Igor Sysoev <igor@sysoev.ru>
parents:
1585
diff
changeset
|
801 break; |
364587232429
compatibility with mget: space after HTTP/1.1
Igor Sysoev <igor@sysoev.ru>
parents:
1585
diff
changeset
|
802 case LF: |
364587232429
compatibility with mget: space after HTTP/1.1
Igor Sysoev <igor@sysoev.ru>
parents:
1585
diff
changeset
|
803 goto done; |
364587232429
compatibility with mget: space after HTTP/1.1
Igor Sysoev <igor@sysoev.ru>
parents:
1585
diff
changeset
|
804 default: |
364587232429
compatibility with mget: space after HTTP/1.1
Igor Sysoev <igor@sysoev.ru>
parents:
1585
diff
changeset
|
805 return NGX_HTTP_PARSE_INVALID_REQUEST; |
364587232429
compatibility with mget: space after HTTP/1.1
Igor Sysoev <igor@sysoev.ru>
parents:
1585
diff
changeset
|
806 } |
364587232429
compatibility with mget: space after HTTP/1.1
Igor Sysoev <igor@sysoev.ru>
parents:
1585
diff
changeset
|
807 break; |
364587232429
compatibility with mget: space after HTTP/1.1
Igor Sysoev <igor@sysoev.ru>
parents:
1585
diff
changeset
|
808 |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
809 /* end of request line */ |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
810 case sw_almost_done: |
479 | 811 r->request_end = p - 1; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
812 switch (ch) { |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
813 case LF: |
479 | 814 goto done; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
815 default: |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
9
diff
changeset
|
816 return NGX_HTTP_PARSE_INVALID_REQUEST; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
817 } |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
818 } |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
819 } |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
820 |
432
11362a3e3911
nginx-0.0.11-2004-09-21-09:38:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
821 b->pos = p; |
479 | 822 r->state = state; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
823 |
479 | 824 return NGX_AGAIN; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
825 |
479 | 826 done: |
827 | |
828 b->pos = p + 1; | |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
829 |
479 | 830 if (r->request_end == NULL) { |
831 r->request_end = p; | |
832 } | |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
833 |
479 | 834 r->http_version = r->http_major * 1000 + r->http_minor; |
835 r->state = sw_start; | |
89
29bf798b583f
nginx-0.0.1-2003-05-15-19:42:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
86
diff
changeset
|
836 |
479 | 837 if (r->http_version == 9 && r->method != NGX_HTTP_GET) { |
838 return NGX_HTTP_PARSE_INVALID_09_METHOD; | |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
839 } |
479 | 840 |
841 return NGX_OK; | |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
842 } |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
843 |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
844 |
509 | 845 ngx_int_t |
2256 | 846 ngx_http_parse_header_line(ngx_http_request_t *r, ngx_buf_t *b, |
847 ngx_uint_t allow_underscores) | |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
848 { |
507 | 849 u_char c, ch, *p; |
649 | 850 ngx_uint_t hash, i; |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
851 enum { |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
852 sw_start = 0, |
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
853 sw_name, |
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
854 sw_space_before_value, |
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
855 sw_value, |
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
856 sw_space_after_value, |
503 | 857 sw_ignore_line, |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
858 sw_almost_done, |
503 | 859 sw_header_almost_done |
21
df7fb216a149
nginx-0.0.1-2002-12-04-19:29:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
18
diff
changeset
|
860 } state; |
df7fb216a149
nginx-0.0.1-2002-12-04-19:29:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
18
diff
changeset
|
861 |
786 | 862 /* the last '\0' is not needed because string is zero terminated */ |
863 | |
649 | 864 static u_char lowcase[] = |
865 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" | |
866 "\0\0\0\0\0\0\0\0\0\0\0\0\0-\0\0" "0123456789\0\0\0\0\0\0" | |
2256 | 867 "\0abcdefghijklmnopqrstuvwxyz\0\0\0\0\0" |
649 | 868 "\0abcdefghijklmnopqrstuvwxyz\0\0\0\0\0" |
869 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" | |
870 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" | |
871 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" | |
786 | 872 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; |
649 | 873 |
21
df7fb216a149
nginx-0.0.1-2002-12-04-19:29:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
18
diff
changeset
|
874 state = r->state; |
507 | 875 hash = r->header_hash; |
649 | 876 i = r->lowcase_index; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
877 |
479 | 878 for (p = b->pos; p < b->last; p++) { |
879 ch = *p; | |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
880 |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
881 switch (state) { |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
882 |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
883 /* first char */ |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
884 case sw_start: |
3079
566eeb81e807
discrease slightly ngx_http_parse_header_line() size:
Igor Sysoev <igor@sysoev.ru>
parents:
3075
diff
changeset
|
885 r->header_name_start = p; |
511 | 886 r->invalid_header = 0; |
887 | |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
888 switch (ch) { |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
889 case CR: |
479 | 890 r->header_end = p; |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
891 state = sw_header_almost_done; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
892 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
893 case LF: |
479 | 894 r->header_end = p; |
895 goto header_done; | |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
896 default: |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
897 state = sw_name; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
898 |
649 | 899 c = lowcase[ch]; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
900 |
649 | 901 if (c) { |
902 hash = ngx_hash(0, c); | |
903 r->lowcase_header[0] = c; | |
904 i = 1; | |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
905 break; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
906 } |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
907 |
5624
bd91f286ee0a
Apply underscores_in_headers also to the first character.
Piotr Sikora <piotr@cloudflare.com>
parents:
5491
diff
changeset
|
908 if (ch == '_') { |
bd91f286ee0a
Apply underscores_in_headers also to the first character.
Piotr Sikora <piotr@cloudflare.com>
parents:
5491
diff
changeset
|
909 if (allow_underscores) { |
bd91f286ee0a
Apply underscores_in_headers also to the first character.
Piotr Sikora <piotr@cloudflare.com>
parents:
5491
diff
changeset
|
910 hash = ngx_hash(0, ch); |
bd91f286ee0a
Apply underscores_in_headers also to the first character.
Piotr Sikora <piotr@cloudflare.com>
parents:
5491
diff
changeset
|
911 r->lowcase_header[0] = ch; |
bd91f286ee0a
Apply underscores_in_headers also to the first character.
Piotr Sikora <piotr@cloudflare.com>
parents:
5491
diff
changeset
|
912 i = 1; |
bd91f286ee0a
Apply underscores_in_headers also to the first character.
Piotr Sikora <piotr@cloudflare.com>
parents:
5491
diff
changeset
|
913 |
bd91f286ee0a
Apply underscores_in_headers also to the first character.
Piotr Sikora <piotr@cloudflare.com>
parents:
5491
diff
changeset
|
914 } else { |
7580
8f55cb5c7e79
Fixed header parsing with ignore_invalid_headers switched off.
Ruslan Ermilov <ru@nginx.com>
parents:
7579
diff
changeset
|
915 hash = 0; |
8f55cb5c7e79
Fixed header parsing with ignore_invalid_headers switched off.
Ruslan Ermilov <ru@nginx.com>
parents:
7579
diff
changeset
|
916 i = 0; |
5624
bd91f286ee0a
Apply underscores_in_headers also to the first character.
Piotr Sikora <piotr@cloudflare.com>
parents:
5491
diff
changeset
|
917 r->invalid_header = 1; |
bd91f286ee0a
Apply underscores_in_headers also to the first character.
Piotr Sikora <piotr@cloudflare.com>
parents:
5491
diff
changeset
|
918 } |
bd91f286ee0a
Apply underscores_in_headers also to the first character.
Piotr Sikora <piotr@cloudflare.com>
parents:
5491
diff
changeset
|
919 |
bd91f286ee0a
Apply underscores_in_headers also to the first character.
Piotr Sikora <piotr@cloudflare.com>
parents:
5491
diff
changeset
|
920 break; |
bd91f286ee0a
Apply underscores_in_headers also to the first character.
Piotr Sikora <piotr@cloudflare.com>
parents:
5491
diff
changeset
|
921 } |
bd91f286ee0a
Apply underscores_in_headers also to the first character.
Piotr Sikora <piotr@cloudflare.com>
parents:
5491
diff
changeset
|
922 |
4530
667aaf61a778
Headers with null character are now rejected.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
923 if (ch == '\0') { |
667aaf61a778
Headers with null character are now rejected.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
924 return NGX_HTTP_PARSE_INVALID_HEADER; |
667aaf61a778
Headers with null character are now rejected.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
925 } |
667aaf61a778
Headers with null character are now rejected.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
926 |
7580
8f55cb5c7e79
Fixed header parsing with ignore_invalid_headers switched off.
Ruslan Ermilov <ru@nginx.com>
parents:
7579
diff
changeset
|
927 hash = 0; |
8f55cb5c7e79
Fixed header parsing with ignore_invalid_headers switched off.
Ruslan Ermilov <ru@nginx.com>
parents:
7579
diff
changeset
|
928 i = 0; |
511 | 929 r->invalid_header = 1; |
930 | |
503 | 931 break; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
932 |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
933 } |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
934 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
935 |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
936 /* header name */ |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
937 case sw_name: |
649 | 938 c = lowcase[ch]; |
939 | |
940 if (c) { | |
941 hash = ngx_hash(hash, c); | |
942 r->lowcase_header[i++] = c; | |
1942 | 943 i &= (NGX_HTTP_LC_HEADER_LEN - 1); |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
944 break; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
945 } |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
946 |
2256 | 947 if (ch == '_') { |
948 if (allow_underscores) { | |
949 hash = ngx_hash(hash, ch); | |
950 r->lowcase_header[i++] = ch; | |
951 i &= (NGX_HTTP_LC_HEADER_LEN - 1); | |
952 | |
953 } else { | |
954 r->invalid_header = 1; | |
955 } | |
956 | |
957 break; | |
958 } | |
959 | |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
960 if (ch == ':') { |
479 | 961 r->header_name_end = p; |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
962 state = sw_space_before_value; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
963 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
964 } |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
965 |
509 | 966 if (ch == CR) { |
967 r->header_name_end = p; | |
968 r->header_start = p; | |
969 r->header_end = p; | |
970 state = sw_almost_done; | |
971 break; | |
972 } | |
973 | |
974 if (ch == LF) { | |
975 r->header_name_end = p; | |
976 r->header_start = p; | |
977 r->header_end = p; | |
978 goto done; | |
979 } | |
980 | |
452 | 981 /* IIS may send the duplicate "HTTP/1.1 ..." lines */ |
72
66de3f065886
nginx-0.0.1-2003-04-09-19:42:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
71
diff
changeset
|
982 if (ch == '/' |
509 | 983 && r->upstream |
984 && p - r->header_name_start == 4 | |
985 && ngx_strncmp(r->header_name_start, "HTTP", 4) == 0) | |
72
66de3f065886
nginx-0.0.1-2003-04-09-19:42:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
71
diff
changeset
|
986 { |
66de3f065886
nginx-0.0.1-2003-04-09-19:42:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
71
diff
changeset
|
987 state = sw_ignore_line; |
66de3f065886
nginx-0.0.1-2003-04-09-19:42:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
71
diff
changeset
|
988 break; |
71
59229033ae93
nginx-0.0.1-2003-04-08-19:40:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
989 } |
59229033ae93
nginx-0.0.1-2003-04-08-19:40:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
990 |
4530
667aaf61a778
Headers with null character are now rejected.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
991 if (ch == '\0') { |
667aaf61a778
Headers with null character are now rejected.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
992 return NGX_HTTP_PARSE_INVALID_HEADER; |
667aaf61a778
Headers with null character are now rejected.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
993 } |
667aaf61a778
Headers with null character are now rejected.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
994 |
511 | 995 r->invalid_header = 1; |
996 | |
503 | 997 break; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
998 |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
999 /* space* before header value */ |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
1000 case sw_space_before_value: |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1001 switch (ch) { |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1002 case ' ': |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1003 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1004 case CR: |
509 | 1005 r->header_start = p; |
1006 r->header_end = p; | |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
1007 state = sw_almost_done; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1008 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1009 case LF: |
509 | 1010 r->header_start = p; |
1011 r->header_end = p; | |
479 | 1012 goto done; |
4530
667aaf61a778
Headers with null character are now rejected.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
1013 case '\0': |
667aaf61a778
Headers with null character are now rejected.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
1014 return NGX_HTTP_PARSE_INVALID_HEADER; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1015 default: |
479 | 1016 r->header_start = p; |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
1017 state = sw_value; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1018 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1019 } |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1020 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1021 |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1022 /* header value */ |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
1023 case sw_value: |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1024 switch (ch) { |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1025 case ' ': |
479 | 1026 r->header_end = p; |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
1027 state = sw_space_after_value; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1028 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1029 case CR: |
479 | 1030 r->header_end = p; |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
1031 state = sw_almost_done; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1032 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1033 case LF: |
479 | 1034 r->header_end = p; |
1035 goto done; | |
4530
667aaf61a778
Headers with null character are now rejected.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
1036 case '\0': |
667aaf61a778
Headers with null character are now rejected.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
1037 return NGX_HTTP_PARSE_INVALID_HEADER; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1038 } |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1039 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1040 |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1041 /* space* before end of header line */ |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
1042 case sw_space_after_value: |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1043 switch (ch) { |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1044 case ' ': |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1045 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1046 case CR: |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
1047 state = sw_almost_done; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1048 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1049 case LF: |
479 | 1050 goto done; |
4530
667aaf61a778
Headers with null character are now rejected.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
1051 case '\0': |
667aaf61a778
Headers with null character are now rejected.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
1052 return NGX_HTTP_PARSE_INVALID_HEADER; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1053 default: |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
1054 state = sw_value; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1055 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1056 } |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1057 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1058 |
71
59229033ae93
nginx-0.0.1-2003-04-08-19:40:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
1059 /* ignore header line */ |
59229033ae93
nginx-0.0.1-2003-04-08-19:40:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
1060 case sw_ignore_line: |
59229033ae93
nginx-0.0.1-2003-04-08-19:40:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
1061 switch (ch) { |
59229033ae93
nginx-0.0.1-2003-04-08-19:40:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
1062 case LF: |
59229033ae93
nginx-0.0.1-2003-04-08-19:40:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
1063 state = sw_start; |
59229033ae93
nginx-0.0.1-2003-04-08-19:40:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
1064 break; |
59229033ae93
nginx-0.0.1-2003-04-08-19:40:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
1065 default: |
59229033ae93
nginx-0.0.1-2003-04-08-19:40:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
1066 break; |
59229033ae93
nginx-0.0.1-2003-04-08-19:40:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
1067 } |
59229033ae93
nginx-0.0.1-2003-04-08-19:40:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
1068 break; |
59229033ae93
nginx-0.0.1-2003-04-08-19:40:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
1069 |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1070 /* end of header line */ |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
1071 case sw_almost_done: |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1072 switch (ch) { |
1943
5acc8bea2c49
test the more likely case first
Igor Sysoev <igor@sysoev.ru>
parents:
1942
diff
changeset
|
1073 case LF: |
5acc8bea2c49
test the more likely case first
Igor Sysoev <igor@sysoev.ru>
parents:
1942
diff
changeset
|
1074 goto done; |
623 | 1075 case CR: |
1076 break; | |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1077 default: |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
9
diff
changeset
|
1078 return NGX_HTTP_PARSE_INVALID_HEADER; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1079 } |
625 | 1080 break; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1081 |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1082 /* end of header */ |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
1083 case sw_header_almost_done: |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1084 switch (ch) { |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1085 case LF: |
479 | 1086 goto header_done; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1087 default: |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
9
diff
changeset
|
1088 return NGX_HTTP_PARSE_INVALID_HEADER; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1089 } |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1090 } |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1091 } |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1092 |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
1093 b->pos = p; |
479 | 1094 r->state = state; |
507 | 1095 r->header_hash = hash; |
649 | 1096 r->lowcase_index = i; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1097 |
479 | 1098 return NGX_AGAIN; |
1099 | |
1100 done: | |
1101 | |
1102 b->pos = p + 1; | |
1103 r->state = sw_start; | |
507 | 1104 r->header_hash = hash; |
649 | 1105 r->lowcase_index = i; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
1106 |
479 | 1107 return NGX_OK; |
1108 | |
1109 header_done: | |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
1110 |
479 | 1111 b->pos = p + 1; |
1112 r->state = sw_start; | |
1113 | |
1114 return NGX_HTTP_PARSE_HEADER_DONE; | |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1115 } |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1116 |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1117 |
509 | 1118 ngx_int_t |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1119 ngx_http_parse_uri(ngx_http_request_t *r) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1120 { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1121 u_char *p, ch; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1122 enum { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1123 sw_start = 0, |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1124 sw_after_slash_in_uri, |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1125 sw_check_uri, |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1126 sw_uri |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1127 } state; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1128 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1129 state = sw_start; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1130 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1131 for (p = r->uri_start; p != r->uri_end; p++) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1132 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1133 ch = *p; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1134 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1135 switch (state) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1136 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1137 case sw_start: |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1138 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1139 if (ch != '/') { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1140 return NGX_ERROR; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1141 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1142 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1143 state = sw_after_slash_in_uri; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1144 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1145 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1146 /* check "/.", "//", "%", and "\" (Win32) in URI */ |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1147 case sw_after_slash_in_uri: |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1148 |
6626
b3682580c1bd
Avoid left-shifting integers into the sign bit, which is undefined.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6543
diff
changeset
|
1149 if (usual[ch >> 5] & (1U << (ch & 0x1f))) { |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1150 state = sw_check_uri; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1151 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1152 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1153 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1154 switch (ch) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1155 case ' ': |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1156 r->space_in_uri = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1157 state = sw_check_uri; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1158 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1159 case '.': |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1160 r->complex_uri = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1161 state = sw_uri; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1162 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1163 case '%': |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1164 r->quoted_uri = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1165 state = sw_uri; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1166 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1167 case '/': |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1168 r->complex_uri = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1169 state = sw_uri; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1170 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1171 #if (NGX_WIN32) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1172 case '\\': |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1173 r->complex_uri = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1174 state = sw_uri; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1175 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1176 #endif |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1177 case '?': |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1178 r->args_start = p + 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1179 state = sw_uri; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1180 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1181 case '#': |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1182 r->complex_uri = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1183 state = sw_uri; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1184 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1185 case '+': |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1186 r->plus_in_uri = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1187 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1188 default: |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1189 state = sw_check_uri; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1190 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1191 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1192 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1193 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1194 /* check "/", "%" and "\" (Win32) in URI */ |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1195 case sw_check_uri: |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1196 |
6626
b3682580c1bd
Avoid left-shifting integers into the sign bit, which is undefined.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6543
diff
changeset
|
1197 if (usual[ch >> 5] & (1U << (ch & 0x1f))) { |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1198 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1199 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1200 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1201 switch (ch) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1202 case '/': |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1203 #if (NGX_WIN32) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1204 if (r->uri_ext == p) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1205 r->complex_uri = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1206 state = sw_uri; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1207 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1208 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1209 #endif |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1210 r->uri_ext = NULL; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1211 state = sw_after_slash_in_uri; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1212 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1213 case '.': |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1214 r->uri_ext = p + 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1215 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1216 case ' ': |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1217 r->space_in_uri = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1218 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1219 #if (NGX_WIN32) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1220 case '\\': |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1221 r->complex_uri = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1222 state = sw_after_slash_in_uri; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1223 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1224 #endif |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1225 case '%': |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1226 r->quoted_uri = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1227 state = sw_uri; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1228 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1229 case '?': |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1230 r->args_start = p + 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1231 state = sw_uri; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1232 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1233 case '#': |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1234 r->complex_uri = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1235 state = sw_uri; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1236 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1237 case '+': |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1238 r->plus_in_uri = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1239 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1240 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1241 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1242 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1243 /* URI */ |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1244 case sw_uri: |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1245 |
6626
b3682580c1bd
Avoid left-shifting integers into the sign bit, which is undefined.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6543
diff
changeset
|
1246 if (usual[ch >> 5] & (1U << (ch & 0x1f))) { |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1247 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1248 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1249 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1250 switch (ch) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1251 case ' ': |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1252 r->space_in_uri = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1253 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1254 case '#': |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1255 r->complex_uri = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1256 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1257 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1258 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1259 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1260 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1261 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1262 return NGX_OK; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1263 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1264 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1265 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1266 ngx_int_t |
1585 | 1267 ngx_http_parse_complex_uri(ngx_http_request_t *r, ngx_uint_t merge_slashes) |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1268 { |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
1269 u_char c, ch, decoded, *p, *u; |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1270 enum { |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1271 sw_usual = 0, |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1272 sw_slash, |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1273 sw_dot, |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1274 sw_dot_dot, |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1275 sw_quoted, |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1276 sw_quoted_second |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1277 } state, quoted_state; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1278 |
479 | 1279 #if (NGX_SUPPRESS_WARN) |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1280 decoded = '\0'; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1281 quoted_state = sw_usual; |
479 | 1282 #endif |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1283 |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1284 state = sw_usual; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1285 p = r->uri_start; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1286 u = r->uri.data; |
201
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
1287 r->uri_ext = NULL; |
461 | 1288 r->args_start = NULL; |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1289 |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1290 ch = *p++; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1291 |
479 | 1292 while (p <= r->uri_end) { |
461 | 1293 |
1294 /* | |
479 | 1295 * we use "ch = *p++" inside the cycle, but this operation is safe, |
4572
67653855682e
Fixed spelling in multiline C comments.
Ruslan Ermilov <ru@nginx.com>
parents:
4546
diff
changeset
|
1296 * because after the URI there is always at least one character: |
461 | 1297 * the line feed |
1298 */ | |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1299 |
5247
55dc535ae5dc
Fixed debug logging in ngx_http_parse_complex_uri().
Maxim Dounin <mdounin@mdounin.ru>
parents:
5189
diff
changeset
|
1300 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
55dc535ae5dc
Fixed debug logging in ngx_http_parse_complex_uri().
Maxim Dounin <mdounin@mdounin.ru>
parents:
5189
diff
changeset
|
1301 "s:%d in:'%Xd:%c'", state, ch, ch); |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1302 |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1303 switch (state) { |
573 | 1304 |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1305 case sw_usual: |
823
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1306 |
6626
b3682580c1bd
Avoid left-shifting integers into the sign bit, which is undefined.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6543
diff
changeset
|
1307 if (usual[ch >> 5] & (1U << (ch & 0x1f))) { |
823
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1308 *u++ = ch; |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1309 ch = *p++; |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1310 break; |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1311 } |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1312 |
5757
c5ec6944de98
Style: add whitespace between control statement and parentheses.
Piotr Sikora <piotr@cloudflare.com>
parents:
5677
diff
changeset
|
1313 switch (ch) { |
461 | 1314 #if (NGX_WIN32) |
1315 case '\\': | |
4674
5d86ab8f2340
Win32: normalization of trailing dot inside uri.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
1316 if (u - 2 >= r->uri.data |
5d86ab8f2340
Win32: normalization of trailing dot inside uri.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
1317 && *(u - 1) == '.' && *(u - 2) != '.') |
5d86ab8f2340
Win32: normalization of trailing dot inside uri.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
1318 { |
5d86ab8f2340
Win32: normalization of trailing dot inside uri.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
1319 u--; |
5d86ab8f2340
Win32: normalization of trailing dot inside uri.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
1320 } |
5d86ab8f2340
Win32: normalization of trailing dot inside uri.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
1321 |
461 | 1322 r->uri_ext = NULL; |
1323 | |
1324 if (p == r->uri_start + r->uri.len) { | |
1325 | |
1326 /* | |
1327 * we omit the last "\" to cause redirect because | |
1328 * the browsers do not treat "\" as "/" in relative URL path | |
1329 */ | |
1330 | |
1331 break; | |
1332 } | |
1333 | |
1334 state = sw_slash; | |
1335 *u++ = '/'; | |
1336 break; | |
1337 #endif | |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1338 case '/': |
4674
5d86ab8f2340
Win32: normalization of trailing dot inside uri.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
1339 #if (NGX_WIN32) |
5d86ab8f2340
Win32: normalization of trailing dot inside uri.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
1340 if (u - 2 >= r->uri.data |
5d86ab8f2340
Win32: normalization of trailing dot inside uri.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
1341 && *(u - 1) == '.' && *(u - 2) != '.') |
5d86ab8f2340
Win32: normalization of trailing dot inside uri.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
1342 { |
5d86ab8f2340
Win32: normalization of trailing dot inside uri.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
1343 u--; |
5d86ab8f2340
Win32: normalization of trailing dot inside uri.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
1344 } |
5d86ab8f2340
Win32: normalization of trailing dot inside uri.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
1345 #endif |
201
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
1346 r->uri_ext = NULL; |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1347 state = sw_slash; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1348 *u++ = ch; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1349 break; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1350 case '%': |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1351 quoted_state = state; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1352 state = sw_quoted; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1353 break; |
461 | 1354 case '?': |
1355 r->args_start = p; | |
820 | 1356 goto args; |
1357 case '#': | |
479 | 1358 goto done; |
201
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
1359 case '.': |
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
1360 r->uri_ext = u + 1; |
473 | 1361 *u++ = ch; |
1362 break; | |
657 | 1363 case '+': |
1364 r->plus_in_uri = 1; | |
4546
4988fa232629
For the sake of case/switch code readability, 'fall through'
Maxim Konovalov <maxim@nginx.com>
parents:
4530
diff
changeset
|
1365 /* fall through */ |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1366 default: |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1367 *u++ = ch; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1368 break; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1369 } |
823
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1370 |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1371 ch = *p++; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1372 break; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1373 |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1374 case sw_slash: |
823
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1375 |
6626
b3682580c1bd
Avoid left-shifting integers into the sign bit, which is undefined.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6543
diff
changeset
|
1376 if (usual[ch >> 5] & (1U << (ch & 0x1f))) { |
823
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1377 state = sw_usual; |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1378 *u++ = ch; |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1379 ch = *p++; |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1380 break; |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1381 } |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1382 |
5757
c5ec6944de98
Style: add whitespace between control statement and parentheses.
Piotr Sikora <piotr@cloudflare.com>
parents:
5677
diff
changeset
|
1383 switch (ch) { |
461 | 1384 #if (NGX_WIN32) |
1385 case '\\': | |
1585 | 1386 break; |
461 | 1387 #endif |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1388 case '/': |
1738 | 1389 if (!merge_slashes) { |
1585 | 1390 *u++ = ch; |
1391 } | |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1392 break; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1393 case '.': |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1394 state = sw_dot; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1395 *u++ = ch; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1396 break; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1397 case '%': |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1398 quoted_state = state; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1399 state = sw_quoted; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1400 break; |
479 | 1401 case '?': |
1402 r->args_start = p; | |
820 | 1403 goto args; |
1404 case '#': | |
479 | 1405 goto done; |
657 | 1406 case '+': |
1407 r->plus_in_uri = 1; | |
6994
f38647c651a8
Added missing "fall through" comments (ticket #1259).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6993
diff
changeset
|
1408 /* fall through */ |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1409 default: |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1410 state = sw_usual; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1411 *u++ = ch; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1412 break; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1413 } |
823
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1414 |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1415 ch = *p++; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1416 break; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1417 |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1418 case sw_dot: |
823
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1419 |
6626
b3682580c1bd
Avoid left-shifting integers into the sign bit, which is undefined.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6543
diff
changeset
|
1420 if (usual[ch >> 5] & (1U << (ch & 0x1f))) { |
823
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1421 state = sw_usual; |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1422 *u++ = ch; |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1423 ch = *p++; |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1424 break; |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1425 } |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1426 |
5757
c5ec6944de98
Style: add whitespace between control statement and parentheses.
Piotr Sikora <piotr@cloudflare.com>
parents:
5677
diff
changeset
|
1427 switch (ch) { |
461 | 1428 #if (NGX_WIN32) |
1429 case '\\': | |
1430 #endif | |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1431 case '/': |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1432 state = sw_slash; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1433 u--; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1434 break; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1435 case '.': |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1436 state = sw_dot_dot; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1437 *u++ = ch; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1438 break; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1439 case '%': |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1440 quoted_state = state; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1441 state = sw_quoted; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1442 break; |
479 | 1443 case '?': |
7578
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1444 u--; |
479 | 1445 r->args_start = p; |
820 | 1446 goto args; |
1447 case '#': | |
7578
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1448 u--; |
479 | 1449 goto done; |
657 | 1450 case '+': |
1451 r->plus_in_uri = 1; | |
6994
f38647c651a8
Added missing "fall through" comments (ticket #1259).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6993
diff
changeset
|
1452 /* fall through */ |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1453 default: |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1454 state = sw_usual; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1455 *u++ = ch; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1456 break; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1457 } |
823
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1458 |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1459 ch = *p++; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1460 break; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1461 |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1462 case sw_dot_dot: |
823
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1463 |
6626
b3682580c1bd
Avoid left-shifting integers into the sign bit, which is undefined.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6543
diff
changeset
|
1464 if (usual[ch >> 5] & (1U << (ch & 0x1f))) { |
823
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1465 state = sw_usual; |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1466 *u++ = ch; |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1467 ch = *p++; |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1468 break; |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1469 } |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1470 |
5757
c5ec6944de98
Style: add whitespace between control statement and parentheses.
Piotr Sikora <piotr@cloudflare.com>
parents:
5677
diff
changeset
|
1471 switch (ch) { |
461 | 1472 #if (NGX_WIN32) |
1473 case '\\': | |
1474 #endif | |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1475 case '/': |
7578
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1476 case '?': |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1477 case '#': |
7579
6208c5418c88
Fixed URI normalization with merge_slashes switched off.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7578
diff
changeset
|
1478 u -= 4; |
3121
bd2573c97e4a
handle "/../" case more reliably
Igor Sysoev <igor@sysoev.ru>
parents:
3079
diff
changeset
|
1479 for ( ;; ) { |
bd2573c97e4a
handle "/../" case more reliably
Igor Sysoev <igor@sysoev.ru>
parents:
3079
diff
changeset
|
1480 if (u < r->uri.data) { |
bd2573c97e4a
handle "/../" case more reliably
Igor Sysoev <igor@sysoev.ru>
parents:
3079
diff
changeset
|
1481 return NGX_HTTP_PARSE_INVALID_REQUEST; |
bd2573c97e4a
handle "/../" case more reliably
Igor Sysoev <igor@sysoev.ru>
parents:
3079
diff
changeset
|
1482 } |
bd2573c97e4a
handle "/../" case more reliably
Igor Sysoev <igor@sysoev.ru>
parents:
3079
diff
changeset
|
1483 if (*u == '/') { |
bd2573c97e4a
handle "/../" case more reliably
Igor Sysoev <igor@sysoev.ru>
parents:
3079
diff
changeset
|
1484 u++; |
bd2573c97e4a
handle "/../" case more reliably
Igor Sysoev <igor@sysoev.ru>
parents:
3079
diff
changeset
|
1485 break; |
bd2573c97e4a
handle "/../" case more reliably
Igor Sysoev <igor@sysoev.ru>
parents:
3079
diff
changeset
|
1486 } |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1487 u--; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1488 } |
7578
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1489 if (ch == '?') { |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1490 r->args_start = p; |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1491 goto args; |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1492 } |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1493 if (ch == '#') { |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1494 goto done; |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1495 } |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1496 state = sw_slash; |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1497 break; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1498 case '%': |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1499 quoted_state = state; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1500 state = sw_quoted; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1501 break; |
657 | 1502 case '+': |
1503 r->plus_in_uri = 1; | |
6994
f38647c651a8
Added missing "fall through" comments (ticket #1259).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6993
diff
changeset
|
1504 /* fall through */ |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1505 default: |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1506 state = sw_usual; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1507 *u++ = ch; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1508 break; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1509 } |
823
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1510 |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1511 ch = *p++; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1512 break; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1513 |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1514 case sw_quoted: |
667 | 1515 r->quoted_uri = 1; |
1516 | |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1517 if (ch >= '0' && ch <= '9') { |
291
117ccc7c4055
nginx-0.0.3-2004-03-16-16:35:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
1518 decoded = (u_char) (ch - '0'); |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1519 state = sw_quoted_second; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1520 ch = *p++; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1521 break; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1522 } |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1523 |
291
117ccc7c4055
nginx-0.0.3-2004-03-16-16:35:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
1524 c = (u_char) (ch | 0x20); |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1525 if (c >= 'a' && c <= 'f') { |
291
117ccc7c4055
nginx-0.0.3-2004-03-16-16:35:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
1526 decoded = (u_char) (c - 'a' + 10); |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1527 state = sw_quoted_second; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1528 ch = *p++; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1529 break; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1530 } |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1531 |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1532 return NGX_HTTP_PARSE_INVALID_REQUEST; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1533 |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1534 case sw_quoted_second: |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1535 if (ch >= '0' && ch <= '9') { |
7067
e3723f2a11b7
Parenthesized ASCII-related calculations.
Valentin Bartenev <vbart@nginx.com>
parents:
6994
diff
changeset
|
1536 ch = (u_char) ((decoded << 4) + (ch - '0')); |
489 | 1537 |
3571
67394153ec39
fix "/dir/%3F../" and "/dir/%23../" cases
Igor Sysoev <igor@sysoev.ru>
parents:
3527
diff
changeset
|
1538 if (ch == '%' || ch == '#') { |
204
e0bcfb77d6c7
nginx-0.0.1-2003-12-02-19:57:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
1539 state = sw_usual; |
e0bcfb77d6c7
nginx-0.0.1-2003-12-02-19:57:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
1540 *u++ = ch; |
e0bcfb77d6c7
nginx-0.0.1-2003-12-02-19:57:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
1541 ch = *p++; |
e0bcfb77d6c7
nginx-0.0.1-2003-12-02-19:57:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
1542 break; |
820 | 1543 |
1544 } else if (ch == '\0') { | |
3527 | 1545 return NGX_HTTP_PARSE_INVALID_REQUEST; |
489 | 1546 } |
1547 | |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1548 state = quoted_state; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1549 break; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1550 } |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1551 |
291
117ccc7c4055
nginx-0.0.3-2004-03-16-16:35:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
1552 c = (u_char) (ch | 0x20); |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1553 if (c >= 'a' && c <= 'f') { |
7067
e3723f2a11b7
Parenthesized ASCII-related calculations.
Valentin Bartenev <vbart@nginx.com>
parents:
6994
diff
changeset
|
1554 ch = (u_char) ((decoded << 4) + (c - 'a') + 10); |
657 | 1555 |
479 | 1556 if (ch == '?') { |
3571
67394153ec39
fix "/dir/%3F../" and "/dir/%23../" cases
Igor Sysoev <igor@sysoev.ru>
parents:
3527
diff
changeset
|
1557 state = sw_usual; |
204
e0bcfb77d6c7
nginx-0.0.1-2003-12-02-19:57:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
1558 *u++ = ch; |
e0bcfb77d6c7
nginx-0.0.1-2003-12-02-19:57:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
1559 ch = *p++; |
3571
67394153ec39
fix "/dir/%3F../" and "/dir/%23../" cases
Igor Sysoev <igor@sysoev.ru>
parents:
3527
diff
changeset
|
1560 break; |
657 | 1561 |
1562 } else if (ch == '+') { | |
1563 r->plus_in_uri = 1; | |
204
e0bcfb77d6c7
nginx-0.0.1-2003-12-02-19:57:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
1564 } |
657 | 1565 |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1566 state = quoted_state; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1567 break; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1568 } |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1569 |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1570 return NGX_HTTP_PARSE_INVALID_REQUEST; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1571 } |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1572 } |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1573 |
7577
5a3426683251
Improved detection of broken percent encoding in URI.
Ruslan Ermilov <ru@nginx.com>
parents:
7562
diff
changeset
|
1574 if (state == sw_quoted || state == sw_quoted_second) { |
5a3426683251
Improved detection of broken percent encoding in URI.
Ruslan Ermilov <ru@nginx.com>
parents:
7562
diff
changeset
|
1575 return NGX_HTTP_PARSE_INVALID_REQUEST; |
5a3426683251
Improved detection of broken percent encoding in URI.
Ruslan Ermilov <ru@nginx.com>
parents:
7562
diff
changeset
|
1576 } |
5a3426683251
Improved detection of broken percent encoding in URI.
Ruslan Ermilov <ru@nginx.com>
parents:
7562
diff
changeset
|
1577 |
7578
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1578 if (state == sw_dot) { |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1579 u--; |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1580 |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1581 } else if (state == sw_dot_dot) { |
7579
6208c5418c88
Fixed URI normalization with merge_slashes switched off.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7578
diff
changeset
|
1582 u -= 4; |
7578
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1583 |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1584 for ( ;; ) { |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1585 if (u < r->uri.data) { |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1586 return NGX_HTTP_PARSE_INVALID_REQUEST; |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1587 } |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1588 |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1589 if (*u == '/') { |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1590 u++; |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1591 break; |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1592 } |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1593 |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1594 u--; |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1595 } |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1596 } |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1597 |
479 | 1598 done: |
1599 | |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1600 r->uri.len = u - r->uri.data; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1601 |
201
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
1602 if (r->uri_ext) { |
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
1603 r->exten.len = u - r->uri_ext; |
461 | 1604 r->exten.data = r->uri_ext; |
201
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
1605 } |
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
1606 |
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
1607 r->uri_ext = NULL; |
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
1608 |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1609 return NGX_OK; |
820 | 1610 |
1611 args: | |
1612 | |
1613 while (p < r->uri_end) { | |
1614 if (*p++ != '#') { | |
1615 continue; | |
1616 } | |
1617 | |
1618 r->args.len = p - 1 - r->args_start; | |
1619 r->args.data = r->args_start; | |
1620 r->args_start = NULL; | |
1621 | |
1622 break; | |
1623 } | |
1624 | |
1625 r->uri.len = u - r->uri.data; | |
1626 | |
1627 if (r->uri_ext) { | |
1628 r->exten.len = u - r->uri_ext; | |
1629 r->exten.data = r->uri_ext; | |
1630 } | |
1631 | |
1632 r->uri_ext = NULL; | |
1633 | |
1634 return NGX_OK; | |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1635 } |
509 | 1636 |
1637 | |
1638 ngx_int_t | |
3626 | 1639 ngx_http_parse_status_line(ngx_http_request_t *r, ngx_buf_t *b, |
1640 ngx_http_status_t *status) | |
1641 { | |
1642 u_char ch; | |
1643 u_char *p; | |
1644 enum { | |
1645 sw_start = 0, | |
1646 sw_H, | |
1647 sw_HT, | |
1648 sw_HTT, | |
1649 sw_HTTP, | |
1650 sw_first_major_digit, | |
1651 sw_major_digit, | |
1652 sw_first_minor_digit, | |
1653 sw_minor_digit, | |
1654 sw_status, | |
1655 sw_space_after_status, | |
1656 sw_status_text, | |
1657 sw_almost_done | |
1658 } state; | |
1659 | |
1660 state = r->state; | |
1661 | |
1662 for (p = b->pos; p < b->last; p++) { | |
1663 ch = *p; | |
1664 | |
1665 switch (state) { | |
1666 | |
1667 /* "HTTP/" */ | |
1668 case sw_start: | |
1669 switch (ch) { | |
1670 case 'H': | |
1671 state = sw_H; | |
1672 break; | |
1673 default: | |
1674 return NGX_ERROR; | |
1675 } | |
1676 break; | |
1677 | |
1678 case sw_H: | |
1679 switch (ch) { | |
1680 case 'T': | |
1681 state = sw_HT; | |
1682 break; | |
1683 default: | |
1684 return NGX_ERROR; | |
1685 } | |
1686 break; | |
1687 | |
1688 case sw_HT: | |
1689 switch (ch) { | |
1690 case 'T': | |
1691 state = sw_HTT; | |
1692 break; | |
1693 default: | |
1694 return NGX_ERROR; | |
1695 } | |
1696 break; | |
1697 | |
1698 case sw_HTT: | |
1699 switch (ch) { | |
1700 case 'P': | |
1701 state = sw_HTTP; | |
1702 break; | |
1703 default: | |
1704 return NGX_ERROR; | |
1705 } | |
1706 break; | |
1707 | |
1708 case sw_HTTP: | |
1709 switch (ch) { | |
1710 case '/': | |
1711 state = sw_first_major_digit; | |
1712 break; | |
1713 default: | |
1714 return NGX_ERROR; | |
1715 } | |
1716 break; | |
1717 | |
1718 /* the first digit of major HTTP version */ | |
1719 case sw_first_major_digit: | |
1720 if (ch < '1' || ch > '9') { | |
1721 return NGX_ERROR; | |
1722 } | |
1723 | |
4125
e5df04b05e75
Protocol version parsing in ngx_http_parse_status_line().
Maxim Dounin <mdounin@mdounin.ru>
parents:
3642
diff
changeset
|
1724 r->http_major = ch - '0'; |
3626 | 1725 state = sw_major_digit; |
1726 break; | |
1727 | |
1728 /* the major HTTP version or dot */ | |
1729 case sw_major_digit: | |
1730 if (ch == '.') { | |
1731 state = sw_first_minor_digit; | |
1732 break; | |
1733 } | |
1734 | |
1735 if (ch < '0' || ch > '9') { | |
1736 return NGX_ERROR; | |
1737 } | |
1738 | |
6543
302ff40c9bc9
Added overflow checks for version numbers (ticket #762).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6014
diff
changeset
|
1739 if (r->http_major > 99) { |
302ff40c9bc9
Added overflow checks for version numbers (ticket #762).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6014
diff
changeset
|
1740 return NGX_ERROR; |
302ff40c9bc9
Added overflow checks for version numbers (ticket #762).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6014
diff
changeset
|
1741 } |
302ff40c9bc9
Added overflow checks for version numbers (ticket #762).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6014
diff
changeset
|
1742 |
7067
e3723f2a11b7
Parenthesized ASCII-related calculations.
Valentin Bartenev <vbart@nginx.com>
parents:
6994
diff
changeset
|
1743 r->http_major = r->http_major * 10 + (ch - '0'); |
3626 | 1744 break; |
1745 | |
1746 /* the first digit of minor HTTP version */ | |
1747 case sw_first_minor_digit: | |
1748 if (ch < '0' || ch > '9') { | |
1749 return NGX_ERROR; | |
1750 } | |
1751 | |
4125
e5df04b05e75
Protocol version parsing in ngx_http_parse_status_line().
Maxim Dounin <mdounin@mdounin.ru>
parents:
3642
diff
changeset
|
1752 r->http_minor = ch - '0'; |
3626 | 1753 state = sw_minor_digit; |
1754 break; | |
1755 | |
1756 /* the minor HTTP version or the end of the request line */ | |
1757 case sw_minor_digit: | |
1758 if (ch == ' ') { | |
1759 state = sw_status; | |
1760 break; | |
1761 } | |
1762 | |
1763 if (ch < '0' || ch > '9') { | |
1764 return NGX_ERROR; | |
1765 } | |
1766 | |
6543
302ff40c9bc9
Added overflow checks for version numbers (ticket #762).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6014
diff
changeset
|
1767 if (r->http_minor > 99) { |
302ff40c9bc9
Added overflow checks for version numbers (ticket #762).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6014
diff
changeset
|
1768 return NGX_ERROR; |
302ff40c9bc9
Added overflow checks for version numbers (ticket #762).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6014
diff
changeset
|
1769 } |
302ff40c9bc9
Added overflow checks for version numbers (ticket #762).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6014
diff
changeset
|
1770 |
7067
e3723f2a11b7
Parenthesized ASCII-related calculations.
Valentin Bartenev <vbart@nginx.com>
parents:
6994
diff
changeset
|
1771 r->http_minor = r->http_minor * 10 + (ch - '0'); |
3626 | 1772 break; |
1773 | |
1774 /* HTTP status code */ | |
1775 case sw_status: | |
1776 if (ch == ' ') { | |
1777 break; | |
1778 } | |
1779 | |
1780 if (ch < '0' || ch > '9') { | |
1781 return NGX_ERROR; | |
1782 } | |
1783 | |
7067
e3723f2a11b7
Parenthesized ASCII-related calculations.
Valentin Bartenev <vbart@nginx.com>
parents:
6994
diff
changeset
|
1784 status->code = status->code * 10 + (ch - '0'); |
3626 | 1785 |
1786 if (++status->count == 3) { | |
1787 state = sw_space_after_status; | |
1788 status->start = p - 2; | |
1789 } | |
1790 | |
1791 break; | |
1792 | |
1793 /* space or end of line */ | |
1794 case sw_space_after_status: | |
1795 switch (ch) { | |
1796 case ' ': | |
1797 state = sw_status_text; | |
1798 break; | |
1799 case '.': /* IIS may send 403.1, 403.2, etc */ | |
1800 state = sw_status_text; | |
1801 break; | |
1802 case CR: | |
1803 state = sw_almost_done; | |
1804 break; | |
1805 case LF: | |
1806 goto done; | |
1807 default: | |
1808 return NGX_ERROR; | |
1809 } | |
1810 break; | |
1811 | |
1812 /* any text until end of line */ | |
1813 case sw_status_text: | |
1814 switch (ch) { | |
1815 case CR: | |
1816 state = sw_almost_done; | |
1817 | |
1818 break; | |
1819 case LF: | |
1820 goto done; | |
1821 } | |
1822 break; | |
1823 | |
1824 /* end of status line */ | |
1825 case sw_almost_done: | |
1826 status->end = p - 1; | |
1827 switch (ch) { | |
1828 case LF: | |
1829 goto done; | |
1830 default: | |
1831 return NGX_ERROR; | |
1832 } | |
1833 } | |
1834 } | |
1835 | |
1836 b->pos = p; | |
1837 r->state = state; | |
1838 | |
1839 return NGX_AGAIN; | |
1840 | |
1841 done: | |
1842 | |
1843 b->pos = p + 1; | |
1844 | |
1845 if (status->end == NULL) { | |
1846 status->end = p; | |
1847 } | |
1848 | |
4125
e5df04b05e75
Protocol version parsing in ngx_http_parse_status_line().
Maxim Dounin <mdounin@mdounin.ru>
parents:
3642
diff
changeset
|
1849 status->http_version = r->http_major * 1000 + r->http_minor; |
3626 | 1850 r->state = sw_start; |
1851 | |
1852 return NGX_OK; | |
1853 } | |
1854 | |
1855 | |
1856 ngx_int_t | |
573 | 1857 ngx_http_parse_unsafe_uri(ngx_http_request_t *r, ngx_str_t *uri, |
1858 ngx_str_t *args, ngx_uint_t *flags) | |
1859 { | |
5491
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1860 u_char ch, *p, *src, *dst; |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1861 size_t len; |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1862 ngx_uint_t quoted; |
573 | 1863 |
1864 len = uri->len; | |
1865 p = uri->data; | |
5491
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1866 quoted = 0; |
573 | 1867 |
1868 if (len == 0 || p[0] == '?') { | |
1869 goto unsafe; | |
1870 } | |
1871 | |
5490
b141a7627ac6
Detect more unsafe URIs in ngx_http_parse_unsafe_uri().
Ruslan Ermilov <ru@nginx.com>
parents:
5442
diff
changeset
|
1872 if (p[0] == '.' && len > 1 && p[1] == '.' |
b141a7627ac6
Detect more unsafe URIs in ngx_http_parse_unsafe_uri().
Ruslan Ermilov <ru@nginx.com>
parents:
5442
diff
changeset
|
1873 && (len == 2 || ngx_path_separator(p[2]))) |
b141a7627ac6
Detect more unsafe URIs in ngx_http_parse_unsafe_uri().
Ruslan Ermilov <ru@nginx.com>
parents:
5442
diff
changeset
|
1874 { |
573 | 1875 goto unsafe; |
1876 } | |
1877 | |
1878 for ( /* void */ ; len; len--) { | |
1879 | |
1880 ch = *p++; | |
1881 | |
5491
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1882 if (ch == '%') { |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1883 quoted = 1; |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1884 continue; |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1885 } |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1886 |
6626
b3682580c1bd
Avoid left-shifting integers into the sign bit, which is undefined.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6543
diff
changeset
|
1887 if (usual[ch >> 5] & (1U << (ch & 0x1f))) { |
823
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1888 continue; |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1889 } |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1890 |
573 | 1891 if (ch == '?') { |
1892 args->len = len - 1; | |
1893 args->data = p; | |
1894 uri->len -= len; | |
1895 | |
5491
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1896 break; |
573 | 1897 } |
1898 | |
1899 if (ch == '\0') { | |
3527 | 1900 goto unsafe; |
573 | 1901 } |
1902 | |
2744 | 1903 if (ngx_path_separator(ch) && len > 2) { |
1904 | |
5490
b141a7627ac6
Detect more unsafe URIs in ngx_http_parse_unsafe_uri().
Ruslan Ermilov <ru@nginx.com>
parents:
5442
diff
changeset
|
1905 /* detect "/../" and "/.." */ |
573 | 1906 |
5490
b141a7627ac6
Detect more unsafe URIs in ngx_http_parse_unsafe_uri().
Ruslan Ermilov <ru@nginx.com>
parents:
5442
diff
changeset
|
1907 if (p[0] == '.' && p[1] == '.' |
b141a7627ac6
Detect more unsafe URIs in ngx_http_parse_unsafe_uri().
Ruslan Ermilov <ru@nginx.com>
parents:
5442
diff
changeset
|
1908 && (len == 3 || ngx_path_separator(p[2]))) |
b141a7627ac6
Detect more unsafe URIs in ngx_http_parse_unsafe_uri().
Ruslan Ermilov <ru@nginx.com>
parents:
5442
diff
changeset
|
1909 { |
573 | 1910 goto unsafe; |
1911 } | |
1912 } | |
1913 } | |
1914 | |
5491
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1915 if (quoted) { |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1916 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1917 "escaped URI: \"%V\"", uri); |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1918 |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1919 src = uri->data; |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1920 |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1921 dst = ngx_pnalloc(r->pool, uri->len); |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1922 if (dst == NULL) { |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1923 return NGX_ERROR; |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1924 } |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1925 |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1926 uri->data = dst; |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1927 |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1928 ngx_unescape_uri(&dst, &src, uri->len, 0); |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1929 |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1930 uri->len = dst - uri->data; |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1931 |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1932 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1933 "unescaped URI: \"%V\"", uri); |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1934 |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1935 len = uri->len; |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1936 p = uri->data; |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1937 |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1938 if (p[0] == '.' && len > 1 && p[1] == '.' |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1939 && (len == 2 || ngx_path_separator(p[2]))) |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1940 { |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1941 goto unsafe; |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1942 } |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1943 |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1944 for ( /* void */ ; len; len--) { |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1945 |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1946 ch = *p++; |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1947 |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1948 if (ch == '\0') { |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1949 goto unsafe; |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1950 } |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1951 |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1952 if (ngx_path_separator(ch) && len > 2) { |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1953 |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1954 /* detect "/../" and "/.." */ |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1955 |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1956 if (p[0] == '.' && p[1] == '.' |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1957 && (len == 3 || ngx_path_separator(p[2]))) |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1958 { |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1959 goto unsafe; |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1960 } |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1961 } |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1962 } |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1963 } |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1964 |
573 | 1965 return NGX_OK; |
1966 | |
1967 unsafe: | |
1968 | |
3161 | 1969 if (*flags & NGX_HTTP_LOG_UNSAFE) { |
1970 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1971 "unsafe URI \"%V\" was detected", uri); | |
1972 } | |
573 | 1973 |
1974 return NGX_ERROR; | |
1975 } | |
1976 | |
1977 | |
1978 ngx_int_t | |
509 | 1979 ngx_http_parse_multi_header_lines(ngx_array_t *headers, ngx_str_t *name, |
1980 ngx_str_t *value) | |
1981 { | |
1982 ngx_uint_t i; | |
1983 u_char *start, *last, *end, ch; | |
1984 ngx_table_elt_t **h; | |
1985 | |
1986 h = headers->elts; | |
1987 | |
1988 for (i = 0; i < headers->nelts; i++) { | |
1989 | |
1990 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, headers->pool->log, 0, | |
1991 "parse header: \"%V: %V\"", &h[i]->key, &h[i]->value); | |
1992 | |
1993 if (name->len > h[i]->value.len) { | |
1994 continue; | |
1995 } | |
577 | 1996 |
509 | 1997 start = h[i]->value.data; |
1998 end = h[i]->value.data + h[i]->value.len; | |
1999 | |
2000 while (start < end) { | |
2001 | |
2002 if (ngx_strncasecmp(start, name->data, name->len) != 0) { | |
2003 goto skip; | |
2004 } | |
2005 | |
2006 for (start += name->len; start < end && *start == ' '; start++) { | |
2007 /* void */ | |
2008 } | |
2009 | |
2010 if (value == NULL) { | |
2011 if (start == end || *start == ',') { | |
2012 return i; | |
2013 } | |
2014 | |
2015 goto skip; | |
2016 } | |
2017 | |
2018 if (start == end || *start++ != '=') { | |
2019 /* the invalid header value */ | |
2020 goto skip; | |
2021 } | |
2022 | |
2023 while (start < end && *start == ' ') { start++; } | |
2024 | |
2025 for (last = start; last < end && *last != ';'; last++) { | |
2026 /* void */ | |
2027 } | |
2028 | |
2029 value->len = last - start; | |
2030 value->data = start; | |
2031 | |
2032 return i; | |
2033 | |
2034 skip: | |
573 | 2035 |
509 | 2036 while (start < end) { |
2037 ch = *start++; | |
2038 if (ch == ';' || ch == ',') { | |
2039 break; | |
2040 } | |
2041 } | |
2042 | |
2043 while (start < end && *start == ' ') { start++; } | |
2044 } | |
2045 } | |
2046 | |
2047 return NGX_DECLINED; | |
2048 } | |
2415 | 2049 |
2050 | |
2051 ngx_int_t | |
5677
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2052 ngx_http_parse_set_cookie_lines(ngx_array_t *headers, ngx_str_t *name, |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2053 ngx_str_t *value) |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2054 { |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2055 ngx_uint_t i; |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2056 u_char *start, *last, *end; |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2057 ngx_table_elt_t **h; |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2058 |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2059 h = headers->elts; |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2060 |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2061 for (i = 0; i < headers->nelts; i++) { |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2062 |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2063 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, headers->pool->log, 0, |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2064 "parse header: \"%V: %V\"", &h[i]->key, &h[i]->value); |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2065 |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2066 if (name->len >= h[i]->value.len) { |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2067 continue; |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2068 } |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2069 |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2070 start = h[i]->value.data; |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2071 end = h[i]->value.data + h[i]->value.len; |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2072 |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2073 if (ngx_strncasecmp(start, name->data, name->len) != 0) { |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2074 continue; |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2075 } |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2076 |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2077 for (start += name->len; start < end && *start == ' '; start++) { |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2078 /* void */ |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2079 } |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2080 |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2081 if (start == end || *start++ != '=') { |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2082 /* the invalid header value */ |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2083 continue; |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2084 } |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2085 |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2086 while (start < end && *start == ' ') { start++; } |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2087 |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2088 for (last = start; last < end && *last != ';'; last++) { |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2089 /* void */ |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2090 } |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2091 |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2092 value->len = last - start; |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2093 value->data = start; |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2094 |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2095 return i; |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2096 } |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2097 |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2098 return NGX_DECLINED; |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2099 } |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2100 |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2101 |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2102 ngx_int_t |
2415 | 2103 ngx_http_arg(ngx_http_request_t *r, u_char *name, size_t len, ngx_str_t *value) |
2104 { | |
2670
20a655d8a1f8
refactor ngx_http_arg() using ngx_strcasestrn(),
Igor Sysoev <igor@sysoev.ru>
parents:
2625
diff
changeset
|
2105 u_char *p, *last; |
2415 | 2106 |
2107 if (r->args.len == 0) { | |
2108 return NGX_DECLINED; | |
2109 } | |
2110 | |
2670
20a655d8a1f8
refactor ngx_http_arg() using ngx_strcasestrn(),
Igor Sysoev <igor@sysoev.ru>
parents:
2625
diff
changeset
|
2111 p = r->args.data; |
20a655d8a1f8
refactor ngx_http_arg() using ngx_strcasestrn(),
Igor Sysoev <igor@sysoev.ru>
parents:
2625
diff
changeset
|
2112 last = p + r->args.len; |
2415 | 2113 |
2670
20a655d8a1f8
refactor ngx_http_arg() using ngx_strcasestrn(),
Igor Sysoev <igor@sysoev.ru>
parents:
2625
diff
changeset
|
2114 for ( /* void */ ; p < last; p++) { |
2415 | 2115 |
2670
20a655d8a1f8
refactor ngx_http_arg() using ngx_strcasestrn(),
Igor Sysoev <igor@sysoev.ru>
parents:
2625
diff
changeset
|
2116 /* we need '=' after name, so drop one char from last */ |
20a655d8a1f8
refactor ngx_http_arg() using ngx_strcasestrn(),
Igor Sysoev <igor@sysoev.ru>
parents:
2625
diff
changeset
|
2117 |
20a655d8a1f8
refactor ngx_http_arg() using ngx_strcasestrn(),
Igor Sysoev <igor@sysoev.ru>
parents:
2625
diff
changeset
|
2118 p = ngx_strlcasestrn(p, last - 1, name, len - 1); |
2415 | 2119 |
2120 if (p == NULL) { | |
2121 return NGX_DECLINED; | |
2122 } | |
2123 | |
2124 if ((p == r->args.data || *(p - 1) == '&') && *(p + len) == '=') { | |
2125 | |
2126 value->data = p + len + 1; | |
2127 | |
2670
20a655d8a1f8
refactor ngx_http_arg() using ngx_strcasestrn(),
Igor Sysoev <igor@sysoev.ru>
parents:
2625
diff
changeset
|
2128 p = ngx_strlchr(p, last, '&'); |
2415 | 2129 |
2130 if (p == NULL) { | |
2131 p = r->args.data + r->args.len; | |
2132 } | |
2133 | |
2134 value->len = p - value->data; | |
2135 | |
2136 return NGX_OK; | |
2137 } | |
2138 } | |
2139 | |
2140 return NGX_DECLINED; | |
2141 } | |
2578 | 2142 |
2143 | |
2144 void | |
2145 ngx_http_split_args(ngx_http_request_t *r, ngx_str_t *uri, ngx_str_t *args) | |
2146 { | |
3527 | 2147 u_char *p, *last; |
2578 | 2148 |
3527 | 2149 last = uri->data + uri->len; |
2625 | 2150 |
3527 | 2151 p = ngx_strlchr(uri->data, last, '?'); |
2578 | 2152 |
3527 | 2153 if (p) { |
2154 uri->len = p - uri->data; | |
2155 p++; | |
2156 args->len = last - p; | |
2157 args->data = p; | |
2578 | 2158 |
3527 | 2159 } else { |
2160 args->len = 0; | |
2578 | 2161 } |
2162 } | |
4925
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2163 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2164 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2165 ngx_int_t |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2166 ngx_http_parse_chunked(ngx_http_request_t *r, ngx_buf_t *b, |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2167 ngx_http_chunked_t *ctx) |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2168 { |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2169 u_char *pos, ch, c; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2170 ngx_int_t rc; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2171 enum { |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2172 sw_chunk_start = 0, |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2173 sw_chunk_size, |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2174 sw_chunk_extension, |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2175 sw_chunk_extension_almost_done, |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2176 sw_chunk_data, |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2177 sw_after_data, |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2178 sw_after_data_almost_done, |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2179 sw_last_chunk_extension, |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2180 sw_last_chunk_extension_almost_done, |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2181 sw_trailer, |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2182 sw_trailer_almost_done, |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2183 sw_trailer_header, |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2184 sw_trailer_header_almost_done |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2185 } state; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2186 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2187 state = ctx->state; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2188 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2189 if (state == sw_chunk_data && ctx->size == 0) { |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2190 state = sw_after_data; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2191 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2192 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2193 rc = NGX_AGAIN; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2194 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2195 for (pos = b->pos; pos < b->last; pos++) { |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2196 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2197 ch = *pos; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2198 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2199 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2200 "http chunked byte: %02Xd s:%d", ch, state); |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2201 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2202 switch (state) { |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2203 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2204 case sw_chunk_start: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2205 if (ch >= '0' && ch <= '9') { |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2206 state = sw_chunk_size; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2207 ctx->size = ch - '0'; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2208 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2209 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2210 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2211 c = (u_char) (ch | 0x20); |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2212 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2213 if (c >= 'a' && c <= 'f') { |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2214 state = sw_chunk_size; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2215 ctx->size = c - 'a' + 10; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2216 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2217 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2218 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2219 goto invalid; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2220 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2221 case sw_chunk_size: |
6014
e370c5fdf4c8
Overflow detection in ngx_http_parse_chunked().
Ruslan Ermilov <ru@nginx.com>
parents:
5757
diff
changeset
|
2222 if (ctx->size > NGX_MAX_OFF_T_VALUE / 16) { |
e370c5fdf4c8
Overflow detection in ngx_http_parse_chunked().
Ruslan Ermilov <ru@nginx.com>
parents:
5757
diff
changeset
|
2223 goto invalid; |
e370c5fdf4c8
Overflow detection in ngx_http_parse_chunked().
Ruslan Ermilov <ru@nginx.com>
parents:
5757
diff
changeset
|
2224 } |
e370c5fdf4c8
Overflow detection in ngx_http_parse_chunked().
Ruslan Ermilov <ru@nginx.com>
parents:
5757
diff
changeset
|
2225 |
4925
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2226 if (ch >= '0' && ch <= '9') { |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2227 ctx->size = ctx->size * 16 + (ch - '0'); |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2228 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2229 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2230 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2231 c = (u_char) (ch | 0x20); |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2232 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2233 if (c >= 'a' && c <= 'f') { |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2234 ctx->size = ctx->size * 16 + (c - 'a' + 10); |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2235 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2236 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2237 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2238 if (ctx->size == 0) { |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2239 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2240 switch (ch) { |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2241 case CR: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2242 state = sw_last_chunk_extension_almost_done; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2243 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2244 case LF: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2245 state = sw_trailer; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2246 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2247 case ';': |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2248 case ' ': |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2249 case '\t': |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2250 state = sw_last_chunk_extension; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2251 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2252 default: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2253 goto invalid; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2254 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2255 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2256 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2257 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2258 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2259 switch (ch) { |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2260 case CR: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2261 state = sw_chunk_extension_almost_done; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2262 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2263 case LF: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2264 state = sw_chunk_data; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2265 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2266 case ';': |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2267 case ' ': |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2268 case '\t': |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2269 state = sw_chunk_extension; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2270 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2271 default: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2272 goto invalid; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2273 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2274 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2275 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2276 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2277 case sw_chunk_extension: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2278 switch (ch) { |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2279 case CR: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2280 state = sw_chunk_extension_almost_done; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2281 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2282 case LF: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2283 state = sw_chunk_data; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2284 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2285 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2286 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2287 case sw_chunk_extension_almost_done: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2288 if (ch == LF) { |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2289 state = sw_chunk_data; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2290 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2291 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2292 goto invalid; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2293 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2294 case sw_chunk_data: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2295 rc = NGX_OK; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2296 goto data; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2297 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2298 case sw_after_data: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2299 switch (ch) { |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2300 case CR: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2301 state = sw_after_data_almost_done; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2302 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2303 case LF: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2304 state = sw_chunk_start; |
7562
52b5ee64fe11
Detect runaway chunks in ngx_http_parse_chunked().
Sergey Kandaurov <pluknet@nginx.com>
parents:
7292
diff
changeset
|
2305 break; |
52b5ee64fe11
Detect runaway chunks in ngx_http_parse_chunked().
Sergey Kandaurov <pluknet@nginx.com>
parents:
7292
diff
changeset
|
2306 default: |
52b5ee64fe11
Detect runaway chunks in ngx_http_parse_chunked().
Sergey Kandaurov <pluknet@nginx.com>
parents:
7292
diff
changeset
|
2307 goto invalid; |
4925
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2308 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2309 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2310 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2311 case sw_after_data_almost_done: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2312 if (ch == LF) { |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2313 state = sw_chunk_start; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2314 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2315 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2316 goto invalid; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2317 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2318 case sw_last_chunk_extension: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2319 switch (ch) { |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2320 case CR: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2321 state = sw_last_chunk_extension_almost_done; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2322 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2323 case LF: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2324 state = sw_trailer; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2325 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2326 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2327 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2328 case sw_last_chunk_extension_almost_done: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2329 if (ch == LF) { |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2330 state = sw_trailer; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2331 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2332 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2333 goto invalid; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2334 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2335 case sw_trailer: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2336 switch (ch) { |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2337 case CR: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2338 state = sw_trailer_almost_done; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2339 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2340 case LF: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2341 goto done; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2342 default: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2343 state = sw_trailer_header; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2344 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2345 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2346 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2347 case sw_trailer_almost_done: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2348 if (ch == LF) { |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2349 goto done; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2350 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2351 goto invalid; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2352 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2353 case sw_trailer_header: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2354 switch (ch) { |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2355 case CR: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2356 state = sw_trailer_header_almost_done; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2357 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2358 case LF: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2359 state = sw_trailer; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2360 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2361 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2362 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2363 case sw_trailer_header_almost_done: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2364 if (ch == LF) { |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2365 state = sw_trailer; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2366 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2367 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2368 goto invalid; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2369 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2370 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2371 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2372 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2373 data: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2374 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2375 ctx->state = state; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2376 b->pos = pos; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2377 |
6014
e370c5fdf4c8
Overflow detection in ngx_http_parse_chunked().
Ruslan Ermilov <ru@nginx.com>
parents:
5757
diff
changeset
|
2378 if (ctx->size > NGX_MAX_OFF_T_VALUE - 5) { |
e370c5fdf4c8
Overflow detection in ngx_http_parse_chunked().
Ruslan Ermilov <ru@nginx.com>
parents:
5757
diff
changeset
|
2379 goto invalid; |
e370c5fdf4c8
Overflow detection in ngx_http_parse_chunked().
Ruslan Ermilov <ru@nginx.com>
parents:
5757
diff
changeset
|
2380 } |
e370c5fdf4c8
Overflow detection in ngx_http_parse_chunked().
Ruslan Ermilov <ru@nginx.com>
parents:
5757
diff
changeset
|
2381 |
4925
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2382 switch (state) { |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2383 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2384 case sw_chunk_start: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2385 ctx->length = 3 /* "0" LF LF */; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2386 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2387 case sw_chunk_size: |
5256
b66ec10e901a
Fixed ngx_http_parse_chunked() minimal length calculation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5247
diff
changeset
|
2388 ctx->length = 1 /* LF */ |
b66ec10e901a
Fixed ngx_http_parse_chunked() minimal length calculation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5247
diff
changeset
|
2389 + (ctx->size ? ctx->size + 4 /* LF "0" LF LF */ |
b66ec10e901a
Fixed ngx_http_parse_chunked() minimal length calculation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5247
diff
changeset
|
2390 : 1 /* LF */); |
4925
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2391 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2392 case sw_chunk_extension: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2393 case sw_chunk_extension_almost_done: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2394 ctx->length = 1 /* LF */ + ctx->size + 4 /* LF "0" LF LF */; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2395 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2396 case sw_chunk_data: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2397 ctx->length = ctx->size + 4 /* LF "0" LF LF */; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2398 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2399 case sw_after_data: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2400 case sw_after_data_almost_done: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2401 ctx->length = 4 /* LF "0" LF LF */; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2402 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2403 case sw_last_chunk_extension: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2404 case sw_last_chunk_extension_almost_done: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2405 ctx->length = 2 /* LF LF */; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2406 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2407 case sw_trailer: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2408 case sw_trailer_almost_done: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2409 ctx->length = 1 /* LF */; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2410 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2411 case sw_trailer_header: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2412 case sw_trailer_header_almost_done: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2413 ctx->length = 2 /* LF LF */; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2414 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2415 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2416 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2417 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2418 return rc; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2419 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2420 done: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2421 |
4926
1c9d8b6523c0
Request body: adjust b->pos when chunked parsing done.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4925
diff
changeset
|
2422 ctx->state = 0; |
1c9d8b6523c0
Request body: adjust b->pos when chunked parsing done.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4925
diff
changeset
|
2423 b->pos = pos + 1; |
1c9d8b6523c0
Request body: adjust b->pos when chunked parsing done.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4925
diff
changeset
|
2424 |
4925
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2425 return NGX_DONE; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2426 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2427 invalid: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2428 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2429 return NGX_ERROR; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2430 } |