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