Mercurial > hg > nginx
annotate src/http/ngx_http_parse.c @ 9300:5be23505292b default tip
SSI: fixed incorrect or duplicate stub output.
Following 3518:eb3aaf8bd2a9 (0.8.37), r->request_output is only set
if there are data in the first buffer sent in the subrequest. As a
result, following the change mentioned this flag cannot be used to
prevent duplicate ngx_http_ssi_stub_output() calls, since it is not
set if there was already some output, but the first buffer was empty.
Still, when there are multiple subrequests, even an empty subrequest
response might be delayed by the postpone filter, leading to a second
call of ngx_http_ssi_stub_output() during finalization from
ngx_http_writer() the subreqest buffers are released by the postpone
filter. Since r->request_output is not set after the first call, this
resulted in duplicate stub output.
Additionally, checking only the first buffer might be wrong in some
unusual cases. For example, the first buffer might be empty if
$r->flush() is called before printing any data in the embedded Perl
module.
Depending on the postpone_output value and corresponding sizes, this
issue can result in either duplicate or unexpected stub output, or
"zero size buf in writer" alerts.
Following 8124:f5515e727656 (1.23.4), it became slightly easier to
reproduce the issue, as empty static files and empty cache items now
result in a response with an empty buffer. Before the change, an empty
proxied response can be used to reproduce the issue.
Fix is check all buffers and set r->request_output if any non-empty
buffers are sent. This ensures that all unusual cases of non-empty
responses are covered, and also that r->request_output will be set
after the first stub output, preventing duplicate output.
Reported by Jan Gassen.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 04 Jul 2024 17:41:28 +0300 |
parents | f53146df9a47 |
children |
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 |
452 | 964 /* 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
|
965 if (ch == '/' |
509 | 966 && r->upstream |
967 && p - r->header_name_start == 4 | |
968 && 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
|
969 { |
66de3f065886
nginx-0.0.1-2003-04-09-19:42:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
71
diff
changeset
|
970 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
|
971 break; |
71
59229033ae93
nginx-0.0.1-2003-04-08-19:40:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
972 } |
59229033ae93
nginx-0.0.1-2003-04-08-19:40:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
973 |
7883
41f4bd4c51f1
Disabled control characters and space in header names.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7882
diff
changeset
|
974 if (ch <= 0x20 || ch == 0x7f) { |
7884
b87b7092cedb
Improved logging of invalid headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7883
diff
changeset
|
975 r->header_end = p; |
4530
667aaf61a778
Headers with null character are now rejected.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
976 return NGX_HTTP_PARSE_INVALID_HEADER; |
667aaf61a778
Headers with null character are now rejected.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
977 } |
667aaf61a778
Headers with null character are now rejected.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
978 |
511 | 979 r->invalid_header = 1; |
980 | |
503 | 981 break; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
982 |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
983 /* 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
|
984 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
|
985 switch (ch) { |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
986 case ' ': |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
987 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
988 case CR: |
509 | 989 r->header_start = p; |
990 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
|
991 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
|
992 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
993 case LF: |
509 | 994 r->header_start = p; |
995 r->header_end = p; | |
479 | 996 goto done; |
4530
667aaf61a778
Headers with null character are now rejected.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
997 case '\0': |
7884
b87b7092cedb
Improved logging of invalid headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7883
diff
changeset
|
998 r->header_end = p; |
4530
667aaf61a778
Headers with null character are now rejected.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
999 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
|
1000 default: |
479 | 1001 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
|
1002 state = sw_value; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1003 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1004 } |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1005 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1006 |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1007 /* header value */ |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
1008 case sw_value: |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1009 switch (ch) { |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1010 case ' ': |
479 | 1011 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
|
1012 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
|
1013 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1014 case CR: |
479 | 1015 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
|
1016 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
|
1017 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1018 case LF: |
479 | 1019 r->header_end = p; |
1020 goto done; | |
4530
667aaf61a778
Headers with null character are now rejected.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
1021 case '\0': |
7884
b87b7092cedb
Improved logging of invalid headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7883
diff
changeset
|
1022 r->header_end = p; |
4530
667aaf61a778
Headers with null character are now rejected.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
1023 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
|
1024 } |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1025 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1026 |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1027 /* 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
|
1028 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
|
1029 switch (ch) { |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1030 case ' ': |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1031 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1032 case CR: |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
1033 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
|
1034 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1035 case LF: |
479 | 1036 goto done; |
4530
667aaf61a778
Headers with null character are now rejected.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
1037 case '\0': |
7884
b87b7092cedb
Improved logging of invalid headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7883
diff
changeset
|
1038 r->header_end = p; |
4530
667aaf61a778
Headers with null character are now rejected.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
1039 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
|
1040 default: |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
1041 state = sw_value; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1042 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1043 } |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1044 break; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1045 |
71
59229033ae93
nginx-0.0.1-2003-04-08-19:40:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
1046 /* ignore header line */ |
59229033ae93
nginx-0.0.1-2003-04-08-19:40:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
1047 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
|
1048 switch (ch) { |
59229033ae93
nginx-0.0.1-2003-04-08-19:40:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
1049 case LF: |
59229033ae93
nginx-0.0.1-2003-04-08-19:40:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
1050 state = sw_start; |
59229033ae93
nginx-0.0.1-2003-04-08-19:40:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
1051 break; |
59229033ae93
nginx-0.0.1-2003-04-08-19:40:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
1052 default: |
59229033ae93
nginx-0.0.1-2003-04-08-19:40:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
1053 break; |
59229033ae93
nginx-0.0.1-2003-04-08-19:40:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
1054 } |
59229033ae93
nginx-0.0.1-2003-04-08-19:40:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
1055 break; |
59229033ae93
nginx-0.0.1-2003-04-08-19:40:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
1056 |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1057 /* 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
|
1058 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
|
1059 switch (ch) { |
1943
5acc8bea2c49
test the more likely case first
Igor Sysoev <igor@sysoev.ru>
parents:
1942
diff
changeset
|
1060 case LF: |
5acc8bea2c49
test the more likely case first
Igor Sysoev <igor@sysoev.ru>
parents:
1942
diff
changeset
|
1061 goto done; |
623 | 1062 case CR: |
1063 break; | |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1064 default: |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
9
diff
changeset
|
1065 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
|
1066 } |
625 | 1067 break; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1068 |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1069 /* 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
|
1070 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
|
1071 switch (ch) { |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1072 case LF: |
479 | 1073 goto header_done; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1074 default: |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
9
diff
changeset
|
1075 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
|
1076 } |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1077 } |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1078 } |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1079 |
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
|
1080 b->pos = p; |
479 | 1081 r->state = state; |
507 | 1082 r->header_hash = hash; |
649 | 1083 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
|
1084 |
479 | 1085 return NGX_AGAIN; |
1086 | |
1087 done: | |
1088 | |
1089 b->pos = p + 1; | |
1090 r->state = sw_start; | |
507 | 1091 r->header_hash = hash; |
649 | 1092 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
|
1093 |
479 | 1094 return NGX_OK; |
1095 | |
1096 header_done: | |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
1097 |
479 | 1098 b->pos = p + 1; |
1099 r->state = sw_start; | |
1100 | |
1101 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
|
1102 } |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1103 |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1104 |
509 | 1105 ngx_int_t |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1106 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
|
1107 { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1108 u_char *p, ch; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1109 enum { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1110 sw_start = 0, |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1111 sw_after_slash_in_uri, |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1112 sw_check_uri, |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1113 sw_uri |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1114 } state; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1115 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1116 state = sw_start; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1117 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1118 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
|
1119 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1120 ch = *p; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1121 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1122 switch (state) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1123 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1124 case sw_start: |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1125 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1126 if (ch != '/') { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1127 return NGX_ERROR; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1128 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1129 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1130 state = sw_after_slash_in_uri; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1131 break; |
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 /* check "/.", "//", "%", and "\" (Win32) in URI */ |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1134 case sw_after_slash_in_uri: |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1135 |
6626
b3682580c1bd
Avoid left-shifting integers into the sign bit, which is undefined.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6543
diff
changeset
|
1136 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
|
1137 state = sw_check_uri; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1138 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1139 } |
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 switch (ch) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1142 case '.': |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1143 r->complex_uri = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1144 state = sw_uri; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1145 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1146 case '%': |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1147 r->quoted_uri = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1148 state = sw_uri; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1149 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1150 case '/': |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1151 r->complex_uri = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1152 state = sw_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 #if (NGX_WIN32) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1155 case '\\': |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1156 r->complex_uri = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1157 state = sw_uri; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1158 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1159 #endif |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1160 case '?': |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1161 r->args_start = p + 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1162 state = sw_uri; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1163 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1164 case '#': |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1165 r->complex_uri = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1166 state = sw_uri; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1167 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1168 case '+': |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1169 r->plus_in_uri = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1170 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1171 default: |
7882
b4073527be81
Disabled control characters in URIs.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7881
diff
changeset
|
1172 if (ch <= 0x20 || ch == 0x7f) { |
b4073527be81
Disabled control characters in URIs.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7881
diff
changeset
|
1173 return NGX_ERROR; |
b4073527be81
Disabled control characters in URIs.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7881
diff
changeset
|
1174 } |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1175 state = sw_check_uri; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1176 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1177 } |
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 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1180 /* check "/", "%" and "\" (Win32) in URI */ |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1181 case sw_check_uri: |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1182 |
6626
b3682580c1bd
Avoid left-shifting integers into the sign bit, which is undefined.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6543
diff
changeset
|
1183 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
|
1184 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1185 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1186 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1187 switch (ch) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1188 case '/': |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1189 #if (NGX_WIN32) |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1190 if (r->uri_ext == p) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1191 r->complex_uri = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1192 state = sw_uri; |
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 #endif |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1196 r->uri_ext = NULL; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1197 state = sw_after_slash_in_uri; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1198 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1199 case '.': |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1200 r->uri_ext = p + 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1201 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1202 #if (NGX_WIN32) |
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 r->complex_uri = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1205 state = sw_after_slash_in_uri; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1206 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1207 #endif |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1208 case '%': |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1209 r->quoted_uri = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1210 state = sw_uri; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1211 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1212 case '?': |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1213 r->args_start = p + 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1214 state = sw_uri; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1215 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1216 case '#': |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1217 r->complex_uri = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1218 state = sw_uri; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1219 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1220 case '+': |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1221 r->plus_in_uri = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1222 break; |
7882
b4073527be81
Disabled control characters in URIs.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7881
diff
changeset
|
1223 default: |
b4073527be81
Disabled control characters in URIs.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7881
diff
changeset
|
1224 if (ch <= 0x20 || ch == 0x7f) { |
b4073527be81
Disabled control characters in URIs.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7881
diff
changeset
|
1225 return NGX_ERROR; |
b4073527be81
Disabled control characters in URIs.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7881
diff
changeset
|
1226 } |
b4073527be81
Disabled control characters in URIs.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7881
diff
changeset
|
1227 break; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1228 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1229 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1230 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1231 /* URI */ |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1232 case sw_uri: |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1233 |
6626
b3682580c1bd
Avoid left-shifting integers into the sign bit, which is undefined.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6543
diff
changeset
|
1234 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
|
1235 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1236 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1237 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1238 switch (ch) { |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1239 case '#': |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1240 r->complex_uri = 1; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1241 break; |
7882
b4073527be81
Disabled control characters in URIs.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7881
diff
changeset
|
1242 default: |
b4073527be81
Disabled control characters in URIs.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7881
diff
changeset
|
1243 if (ch <= 0x20 || ch == 0x7f) { |
b4073527be81
Disabled control characters in URIs.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7881
diff
changeset
|
1244 return NGX_ERROR; |
b4073527be81
Disabled control characters in URIs.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7881
diff
changeset
|
1245 } |
b4073527be81
Disabled control characters in URIs.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7881
diff
changeset
|
1246 break; |
5121
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1247 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1248 break; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1249 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1250 } |
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 return NGX_OK; |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1253 } |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1254 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1255 |
c0f7b94e88ba
Preliminary experimental support for SPDY draft 2.
Valentin Bartenev <vbart@nginx.com>
parents:
4926
diff
changeset
|
1256 ngx_int_t |
1585 | 1257 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
|
1258 { |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
1259 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
|
1260 enum { |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1261 sw_usual = 0, |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1262 sw_slash, |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1263 sw_dot, |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1264 sw_dot_dot, |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1265 sw_quoted, |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1266 sw_quoted_second |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1267 } state, quoted_state; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1268 |
479 | 1269 #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
|
1270 decoded = '\0'; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1271 quoted_state = sw_usual; |
479 | 1272 #endif |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1273 |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1274 state = sw_usual; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1275 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
|
1276 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
|
1277 r->uri_ext = NULL; |
461 | 1278 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
|
1279 |
7752
8989fbd2f89a
Fixed parsing of absolute URIs with empty path (ticket #2079).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7580
diff
changeset
|
1280 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
|
1281 *u++ = '/'; |
8989fbd2f89a
Fixed parsing of absolute URIs with empty path (ticket #2079).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7580
diff
changeset
|
1282 } |
8989fbd2f89a
Fixed parsing of absolute URIs with empty path (ticket #2079).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7580
diff
changeset
|
1283 |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1284 ch = *p++; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1285 |
479 | 1286 while (p <= r->uri_end) { |
461 | 1287 |
1288 /* | |
479 | 1289 * 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
|
1290 * because after the URI there is always at least one character: |
461 | 1291 * the line feed |
1292 */ | |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1293 |
5247
55dc535ae5dc
Fixed debug logging in ngx_http_parse_complex_uri().
Maxim Dounin <mdounin@mdounin.ru>
parents:
5189
diff
changeset
|
1294 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
|
1295 "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
|
1296 |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1297 switch (state) { |
573 | 1298 |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1299 case sw_usual: |
823
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1300 |
6626
b3682580c1bd
Avoid left-shifting integers into the sign bit, which is undefined.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6543
diff
changeset
|
1301 if (usual[ch >> 5] & (1U << (ch & 0x1f))) { |
823
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1302 *u++ = ch; |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1303 ch = *p++; |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1304 break; |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1305 } |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1306 |
5757
c5ec6944de98
Style: add whitespace between control statement and parentheses.
Piotr Sikora <piotr@cloudflare.com>
parents:
5677
diff
changeset
|
1307 switch (ch) { |
461 | 1308 #if (NGX_WIN32) |
1309 case '\\': | |
4674
5d86ab8f2340
Win32: normalization of trailing dot inside uri.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
1310 if (u - 2 >= r->uri.data |
5d86ab8f2340
Win32: normalization of trailing dot inside uri.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
1311 && *(u - 1) == '.' && *(u - 2) != '.') |
5d86ab8f2340
Win32: normalization of trailing dot inside uri.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
1312 { |
5d86ab8f2340
Win32: normalization of trailing dot inside uri.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
1313 u--; |
5d86ab8f2340
Win32: normalization of trailing dot inside uri.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
1314 } |
5d86ab8f2340
Win32: normalization of trailing dot inside uri.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
1315 |
461 | 1316 r->uri_ext = NULL; |
1317 | |
1318 if (p == r->uri_start + r->uri.len) { | |
1319 | |
1320 /* | |
1321 * we omit the last "\" to cause redirect because | |
1322 * the browsers do not treat "\" as "/" in relative URL path | |
1323 */ | |
1324 | |
1325 break; | |
1326 } | |
1327 | |
1328 state = sw_slash; | |
1329 *u++ = '/'; | |
1330 break; | |
1331 #endif | |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1332 case '/': |
4674
5d86ab8f2340
Win32: normalization of trailing dot inside uri.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
1333 #if (NGX_WIN32) |
5d86ab8f2340
Win32: normalization of trailing dot inside uri.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
1334 if (u - 2 >= r->uri.data |
5d86ab8f2340
Win32: normalization of trailing dot inside uri.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
1335 && *(u - 1) == '.' && *(u - 2) != '.') |
5d86ab8f2340
Win32: normalization of trailing dot inside uri.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
1336 { |
5d86ab8f2340
Win32: normalization of trailing dot inside uri.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
1337 u--; |
5d86ab8f2340
Win32: normalization of trailing dot inside uri.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
1338 } |
5d86ab8f2340
Win32: normalization of trailing dot inside uri.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
1339 #endif |
201
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
1340 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
|
1341 state = sw_slash; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1342 *u++ = ch; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1343 break; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1344 case '%': |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1345 quoted_state = state; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1346 state = sw_quoted; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1347 break; |
461 | 1348 case '?': |
1349 r->args_start = p; | |
820 | 1350 goto args; |
1351 case '#': | |
479 | 1352 goto done; |
201
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
1353 case '.': |
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
1354 r->uri_ext = u + 1; |
473 | 1355 *u++ = ch; |
1356 break; | |
657 | 1357 case '+': |
1358 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
|
1359 /* fall through */ |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1360 default: |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1361 *u++ = ch; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1362 break; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1363 } |
823
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1364 |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1365 ch = *p++; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1366 break; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1367 |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1368 case sw_slash: |
823
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1369 |
6626
b3682580c1bd
Avoid left-shifting integers into the sign bit, which is undefined.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6543
diff
changeset
|
1370 if (usual[ch >> 5] & (1U << (ch & 0x1f))) { |
823
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1371 state = sw_usual; |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1372 *u++ = ch; |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1373 ch = *p++; |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1374 break; |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1375 } |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1376 |
5757
c5ec6944de98
Style: add whitespace between control statement and parentheses.
Piotr Sikora <piotr@cloudflare.com>
parents:
5677
diff
changeset
|
1377 switch (ch) { |
461 | 1378 #if (NGX_WIN32) |
1379 case '\\': | |
1585 | 1380 break; |
461 | 1381 #endif |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1382 case '/': |
1738 | 1383 if (!merge_slashes) { |
1585 | 1384 *u++ = ch; |
1385 } | |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1386 break; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1387 case '.': |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1388 state = sw_dot; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1389 *u++ = ch; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1390 break; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1391 case '%': |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1392 quoted_state = state; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1393 state = sw_quoted; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1394 break; |
479 | 1395 case '?': |
1396 r->args_start = p; | |
820 | 1397 goto args; |
1398 case '#': | |
479 | 1399 goto done; |
657 | 1400 case '+': |
1401 r->plus_in_uri = 1; | |
6994
f38647c651a8
Added missing "fall through" comments (ticket #1259).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6993
diff
changeset
|
1402 /* fall through */ |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1403 default: |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1404 state = sw_usual; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1405 *u++ = ch; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1406 break; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1407 } |
823
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1408 |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1409 ch = *p++; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1410 break; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1411 |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1412 case sw_dot: |
823
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1413 |
6626
b3682580c1bd
Avoid left-shifting integers into the sign bit, which is undefined.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6543
diff
changeset
|
1414 if (usual[ch >> 5] & (1U << (ch & 0x1f))) { |
823
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1415 state = sw_usual; |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1416 *u++ = ch; |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1417 ch = *p++; |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1418 break; |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1419 } |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1420 |
5757
c5ec6944de98
Style: add whitespace between control statement and parentheses.
Piotr Sikora <piotr@cloudflare.com>
parents:
5677
diff
changeset
|
1421 switch (ch) { |
461 | 1422 #if (NGX_WIN32) |
1423 case '\\': | |
1424 #endif | |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1425 case '/': |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1426 state = sw_slash; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1427 u--; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1428 break; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1429 case '.': |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1430 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
|
1431 *u++ = ch; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1432 break; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1433 case '%': |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1434 quoted_state = state; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1435 state = sw_quoted; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1436 break; |
479 | 1437 case '?': |
7578
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1438 u--; |
479 | 1439 r->args_start = p; |
820 | 1440 goto args; |
1441 case '#': | |
7578
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1442 u--; |
479 | 1443 goto done; |
657 | 1444 case '+': |
1445 r->plus_in_uri = 1; | |
6994
f38647c651a8
Added missing "fall through" comments (ticket #1259).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6993
diff
changeset
|
1446 /* fall through */ |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1447 default: |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1448 state = sw_usual; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1449 *u++ = ch; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1450 break; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1451 } |
823
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1452 |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1453 ch = *p++; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1454 break; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1455 |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1456 case sw_dot_dot: |
823
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1457 |
6626
b3682580c1bd
Avoid left-shifting integers into the sign bit, which is undefined.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6543
diff
changeset
|
1458 if (usual[ch >> 5] & (1U << (ch & 0x1f))) { |
823
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1459 state = sw_usual; |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1460 *u++ = ch; |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1461 ch = *p++; |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1462 break; |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1463 } |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1464 |
5757
c5ec6944de98
Style: add whitespace between control statement and parentheses.
Piotr Sikora <piotr@cloudflare.com>
parents:
5677
diff
changeset
|
1465 switch (ch) { |
461 | 1466 #if (NGX_WIN32) |
1467 case '\\': | |
1468 #endif | |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1469 case '/': |
7578
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1470 case '?': |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1471 case '#': |
7579
6208c5418c88
Fixed URI normalization with merge_slashes switched off.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7578
diff
changeset
|
1472 u -= 4; |
3121
bd2573c97e4a
handle "/../" case more reliably
Igor Sysoev <igor@sysoev.ru>
parents:
3079
diff
changeset
|
1473 for ( ;; ) { |
bd2573c97e4a
handle "/../" case more reliably
Igor Sysoev <igor@sysoev.ru>
parents:
3079
diff
changeset
|
1474 if (u < r->uri.data) { |
bd2573c97e4a
handle "/../" case more reliably
Igor Sysoev <igor@sysoev.ru>
parents:
3079
diff
changeset
|
1475 return NGX_HTTP_PARSE_INVALID_REQUEST; |
bd2573c97e4a
handle "/../" case more reliably
Igor Sysoev <igor@sysoev.ru>
parents:
3079
diff
changeset
|
1476 } |
bd2573c97e4a
handle "/../" case more reliably
Igor Sysoev <igor@sysoev.ru>
parents:
3079
diff
changeset
|
1477 if (*u == '/') { |
bd2573c97e4a
handle "/../" case more reliably
Igor Sysoev <igor@sysoev.ru>
parents:
3079
diff
changeset
|
1478 u++; |
bd2573c97e4a
handle "/../" case more reliably
Igor Sysoev <igor@sysoev.ru>
parents:
3079
diff
changeset
|
1479 break; |
bd2573c97e4a
handle "/../" case more reliably
Igor Sysoev <igor@sysoev.ru>
parents:
3079
diff
changeset
|
1480 } |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1481 u--; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1482 } |
7578
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1483 if (ch == '?') { |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1484 r->args_start = p; |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1485 goto args; |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1486 } |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1487 if (ch == '#') { |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1488 goto done; |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1489 } |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1490 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
|
1491 break; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1492 case '%': |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1493 quoted_state = state; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1494 state = sw_quoted; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1495 break; |
657 | 1496 case '+': |
1497 r->plus_in_uri = 1; | |
6994
f38647c651a8
Added missing "fall through" comments (ticket #1259).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6993
diff
changeset
|
1498 /* fall through */ |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1499 default: |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1500 state = sw_usual; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1501 *u++ = ch; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1502 break; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1503 } |
823
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1504 |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1505 ch = *p++; |
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 |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1508 case sw_quoted: |
667 | 1509 r->quoted_uri = 1; |
1510 | |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1511 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
|
1512 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
|
1513 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
|
1514 ch = *p++; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1515 break; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1516 } |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1517 |
291
117ccc7c4055
nginx-0.0.3-2004-03-16-16:35:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
1518 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
|
1519 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
|
1520 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
|
1521 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
|
1522 ch = *p++; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1523 break; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1524 } |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1525 |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1526 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
|
1527 |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1528 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
|
1529 if (ch >= '0' && ch <= '9') { |
7067
e3723f2a11b7
Parenthesized ASCII-related calculations.
Valentin Bartenev <vbart@nginx.com>
parents:
6994
diff
changeset
|
1530 ch = (u_char) ((decoded << 4) + (ch - '0')); |
489 | 1531 |
3571
67394153ec39
fix "/dir/%3F../" and "/dir/%23../" cases
Igor Sysoev <igor@sysoev.ru>
parents:
3527
diff
changeset
|
1532 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
|
1533 state = sw_usual; |
e0bcfb77d6c7
nginx-0.0.1-2003-12-02-19:57:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
1534 *u++ = ch; |
e0bcfb77d6c7
nginx-0.0.1-2003-12-02-19:57:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
1535 ch = *p++; |
e0bcfb77d6c7
nginx-0.0.1-2003-12-02-19:57:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
1536 break; |
820 | 1537 |
1538 } else if (ch == '\0') { | |
3527 | 1539 return NGX_HTTP_PARSE_INVALID_REQUEST; |
489 | 1540 } |
1541 | |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1542 state = quoted_state; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1543 break; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1544 } |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1545 |
291
117ccc7c4055
nginx-0.0.3-2004-03-16-16:35:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
1546 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
|
1547 if (c >= 'a' && c <= 'f') { |
7067
e3723f2a11b7
Parenthesized ASCII-related calculations.
Valentin Bartenev <vbart@nginx.com>
parents:
6994
diff
changeset
|
1548 ch = (u_char) ((decoded << 4) + (c - 'a') + 10); |
657 | 1549 |
479 | 1550 if (ch == '?') { |
3571
67394153ec39
fix "/dir/%3F../" and "/dir/%23../" cases
Igor Sysoev <igor@sysoev.ru>
parents:
3527
diff
changeset
|
1551 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
|
1552 *u++ = ch; |
e0bcfb77d6c7
nginx-0.0.1-2003-12-02-19:57:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
1553 ch = *p++; |
3571
67394153ec39
fix "/dir/%3F../" and "/dir/%23../" cases
Igor Sysoev <igor@sysoev.ru>
parents:
3527
diff
changeset
|
1554 break; |
657 | 1555 |
1556 } else if (ch == '+') { | |
1557 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
|
1558 } |
657 | 1559 |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1560 state = quoted_state; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1561 break; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1562 } |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1563 |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1564 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
|
1565 } |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1566 } |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1567 |
7577
5a3426683251
Improved detection of broken percent encoding in URI.
Ruslan Ermilov <ru@nginx.com>
parents:
7562
diff
changeset
|
1568 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
|
1569 return NGX_HTTP_PARSE_INVALID_REQUEST; |
5a3426683251
Improved detection of broken percent encoding in URI.
Ruslan Ermilov <ru@nginx.com>
parents:
7562
diff
changeset
|
1570 } |
5a3426683251
Improved detection of broken percent encoding in URI.
Ruslan Ermilov <ru@nginx.com>
parents:
7562
diff
changeset
|
1571 |
7578
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1572 if (state == sw_dot) { |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1573 u--; |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1574 |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1575 } 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
|
1576 u -= 4; |
7578
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1577 |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1578 for ( ;; ) { |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1579 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
|
1580 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
|
1581 } |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1582 |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1583 if (*u == '/') { |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1584 u++; |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1585 break; |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1586 } |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1587 |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1588 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 } |
79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
Ruslan Ermilov <ru@nginx.com>
parents:
7577
diff
changeset
|
1591 |
479 | 1592 done: |
1593 | |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1594 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
|
1595 |
201
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
1596 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
|
1597 r->exten.len = u - r->uri_ext; |
461 | 1598 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
|
1599 } |
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
1600 |
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
1601 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
|
1602 |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
1603 return NGX_OK; |
820 | 1604 |
1605 args: | |
1606 | |
1607 while (p < r->uri_end) { | |
1608 if (*p++ != '#') { | |
1609 continue; | |
1610 } | |
1611 | |
1612 r->args.len = p - 1 - r->args_start; | |
1613 r->args.data = r->args_start; | |
1614 r->args_start = NULL; | |
1615 | |
1616 break; | |
1617 } | |
1618 | |
1619 r->uri.len = u - r->uri.data; | |
1620 | |
1621 if (r->uri_ext) { | |
1622 r->exten.len = u - r->uri_ext; | |
1623 r->exten.data = r->uri_ext; | |
1624 } | |
1625 | |
1626 r->uri_ext = NULL; | |
1627 | |
1628 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
|
1629 } |
509 | 1630 |
1631 | |
1632 ngx_int_t | |
3626 | 1633 ngx_http_parse_status_line(ngx_http_request_t *r, ngx_buf_t *b, |
1634 ngx_http_status_t *status) | |
1635 { | |
1636 u_char ch; | |
1637 u_char *p; | |
1638 enum { | |
1639 sw_start = 0, | |
1640 sw_H, | |
1641 sw_HT, | |
1642 sw_HTT, | |
1643 sw_HTTP, | |
1644 sw_first_major_digit, | |
1645 sw_major_digit, | |
1646 sw_first_minor_digit, | |
1647 sw_minor_digit, | |
1648 sw_status, | |
1649 sw_space_after_status, | |
1650 sw_status_text, | |
1651 sw_almost_done | |
1652 } state; | |
1653 | |
1654 state = r->state; | |
1655 | |
1656 for (p = b->pos; p < b->last; p++) { | |
1657 ch = *p; | |
1658 | |
1659 switch (state) { | |
1660 | |
1661 /* "HTTP/" */ | |
1662 case sw_start: | |
1663 switch (ch) { | |
1664 case 'H': | |
1665 state = sw_H; | |
1666 break; | |
1667 default: | |
1668 return NGX_ERROR; | |
1669 } | |
1670 break; | |
1671 | |
1672 case sw_H: | |
1673 switch (ch) { | |
1674 case 'T': | |
1675 state = sw_HT; | |
1676 break; | |
1677 default: | |
1678 return NGX_ERROR; | |
1679 } | |
1680 break; | |
1681 | |
1682 case sw_HT: | |
1683 switch (ch) { | |
1684 case 'T': | |
1685 state = sw_HTT; | |
1686 break; | |
1687 default: | |
1688 return NGX_ERROR; | |
1689 } | |
1690 break; | |
1691 | |
1692 case sw_HTT: | |
1693 switch (ch) { | |
1694 case 'P': | |
1695 state = sw_HTTP; | |
1696 break; | |
1697 default: | |
1698 return NGX_ERROR; | |
1699 } | |
1700 break; | |
1701 | |
1702 case sw_HTTP: | |
1703 switch (ch) { | |
1704 case '/': | |
1705 state = sw_first_major_digit; | |
1706 break; | |
1707 default: | |
1708 return NGX_ERROR; | |
1709 } | |
1710 break; | |
1711 | |
1712 /* the first digit of major HTTP version */ | |
1713 case sw_first_major_digit: | |
1714 if (ch < '1' || ch > '9') { | |
1715 return NGX_ERROR; | |
1716 } | |
1717 | |
4125
e5df04b05e75
Protocol version parsing in ngx_http_parse_status_line().
Maxim Dounin <mdounin@mdounin.ru>
parents:
3642
diff
changeset
|
1718 r->http_major = ch - '0'; |
3626 | 1719 state = sw_major_digit; |
1720 break; | |
1721 | |
1722 /* the major HTTP version or dot */ | |
1723 case sw_major_digit: | |
1724 if (ch == '.') { | |
1725 state = sw_first_minor_digit; | |
1726 break; | |
1727 } | |
1728 | |
1729 if (ch < '0' || ch > '9') { | |
1730 return NGX_ERROR; | |
1731 } | |
1732 | |
6543
302ff40c9bc9
Added overflow checks for version numbers (ticket #762).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6014
diff
changeset
|
1733 if (r->http_major > 99) { |
302ff40c9bc9
Added overflow checks for version numbers (ticket #762).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6014
diff
changeset
|
1734 return NGX_ERROR; |
302ff40c9bc9
Added overflow checks for version numbers (ticket #762).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6014
diff
changeset
|
1735 } |
302ff40c9bc9
Added overflow checks for version numbers (ticket #762).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6014
diff
changeset
|
1736 |
7067
e3723f2a11b7
Parenthesized ASCII-related calculations.
Valentin Bartenev <vbart@nginx.com>
parents:
6994
diff
changeset
|
1737 r->http_major = r->http_major * 10 + (ch - '0'); |
3626 | 1738 break; |
1739 | |
1740 /* the first digit of minor HTTP version */ | |
1741 case sw_first_minor_digit: | |
1742 if (ch < '0' || ch > '9') { | |
1743 return NGX_ERROR; | |
1744 } | |
1745 | |
4125
e5df04b05e75
Protocol version parsing in ngx_http_parse_status_line().
Maxim Dounin <mdounin@mdounin.ru>
parents:
3642
diff
changeset
|
1746 r->http_minor = ch - '0'; |
3626 | 1747 state = sw_minor_digit; |
1748 break; | |
1749 | |
1750 /* the minor HTTP version or the end of the request line */ | |
1751 case sw_minor_digit: | |
1752 if (ch == ' ') { | |
1753 state = sw_status; | |
1754 break; | |
1755 } | |
1756 | |
1757 if (ch < '0' || ch > '9') { | |
1758 return NGX_ERROR; | |
1759 } | |
1760 | |
6543
302ff40c9bc9
Added overflow checks for version numbers (ticket #762).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6014
diff
changeset
|
1761 if (r->http_minor > 99) { |
302ff40c9bc9
Added overflow checks for version numbers (ticket #762).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6014
diff
changeset
|
1762 return NGX_ERROR; |
302ff40c9bc9
Added overflow checks for version numbers (ticket #762).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6014
diff
changeset
|
1763 } |
302ff40c9bc9
Added overflow checks for version numbers (ticket #762).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6014
diff
changeset
|
1764 |
7067
e3723f2a11b7
Parenthesized ASCII-related calculations.
Valentin Bartenev <vbart@nginx.com>
parents:
6994
diff
changeset
|
1765 r->http_minor = r->http_minor * 10 + (ch - '0'); |
3626 | 1766 break; |
1767 | |
1768 /* HTTP status code */ | |
1769 case sw_status: | |
1770 if (ch == ' ') { | |
1771 break; | |
1772 } | |
1773 | |
1774 if (ch < '0' || ch > '9') { | |
1775 return NGX_ERROR; | |
1776 } | |
1777 | |
7067
e3723f2a11b7
Parenthesized ASCII-related calculations.
Valentin Bartenev <vbart@nginx.com>
parents:
6994
diff
changeset
|
1778 status->code = status->code * 10 + (ch - '0'); |
3626 | 1779 |
1780 if (++status->count == 3) { | |
1781 state = sw_space_after_status; | |
1782 status->start = p - 2; | |
1783 } | |
1784 | |
1785 break; | |
1786 | |
1787 /* space or end of line */ | |
1788 case sw_space_after_status: | |
1789 switch (ch) { | |
1790 case ' ': | |
1791 state = sw_status_text; | |
1792 break; | |
1793 case '.': /* IIS may send 403.1, 403.2, etc */ | |
1794 state = sw_status_text; | |
1795 break; | |
1796 case CR: | |
1797 state = sw_almost_done; | |
1798 break; | |
1799 case LF: | |
1800 goto done; | |
1801 default: | |
1802 return NGX_ERROR; | |
1803 } | |
1804 break; | |
1805 | |
1806 /* any text until end of line */ | |
1807 case sw_status_text: | |
1808 switch (ch) { | |
1809 case CR: | |
1810 state = sw_almost_done; | |
1811 | |
1812 break; | |
1813 case LF: | |
1814 goto done; | |
1815 } | |
1816 break; | |
1817 | |
1818 /* end of status line */ | |
1819 case sw_almost_done: | |
1820 status->end = p - 1; | |
1821 switch (ch) { | |
1822 case LF: | |
1823 goto done; | |
1824 default: | |
1825 return NGX_ERROR; | |
1826 } | |
1827 } | |
1828 } | |
1829 | |
1830 b->pos = p; | |
1831 r->state = state; | |
1832 | |
1833 return NGX_AGAIN; | |
1834 | |
1835 done: | |
1836 | |
1837 b->pos = p + 1; | |
1838 | |
1839 if (status->end == NULL) { | |
1840 status->end = p; | |
1841 } | |
1842 | |
4125
e5df04b05e75
Protocol version parsing in ngx_http_parse_status_line().
Maxim Dounin <mdounin@mdounin.ru>
parents:
3642
diff
changeset
|
1843 status->http_version = r->http_major * 1000 + r->http_minor; |
3626 | 1844 r->state = sw_start; |
1845 | |
1846 return NGX_OK; | |
1847 } | |
1848 | |
1849 | |
1850 ngx_int_t | |
573 | 1851 ngx_http_parse_unsafe_uri(ngx_http_request_t *r, ngx_str_t *uri, |
1852 ngx_str_t *args, ngx_uint_t *flags) | |
1853 { | |
5491
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1854 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
|
1855 size_t len; |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1856 ngx_uint_t quoted; |
573 | 1857 |
1858 len = uri->len; | |
1859 p = uri->data; | |
5491
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1860 quoted = 0; |
573 | 1861 |
1862 if (len == 0 || p[0] == '?') { | |
1863 goto unsafe; | |
1864 } | |
1865 | |
5490
b141a7627ac6
Detect more unsafe URIs in ngx_http_parse_unsafe_uri().
Ruslan Ermilov <ru@nginx.com>
parents:
5442
diff
changeset
|
1866 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
|
1867 && (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
|
1868 { |
573 | 1869 goto unsafe; |
1870 } | |
1871 | |
1872 for ( /* void */ ; len; len--) { | |
1873 | |
1874 ch = *p++; | |
1875 | |
5491
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1876 if (ch == '%') { |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1877 quoted = 1; |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1878 continue; |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1879 } |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1880 |
6626
b3682580c1bd
Avoid left-shifting integers into the sign bit, which is undefined.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6543
diff
changeset
|
1881 if (usual[ch >> 5] & (1U << (ch & 0x1f))) { |
823
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1882 continue; |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1883 } |
ccf3c59f8040
optimize the most frequent cases
Igor Sysoev <igor@sysoev.ru>
parents:
822
diff
changeset
|
1884 |
573 | 1885 if (ch == '?') { |
1886 args->len = len - 1; | |
1887 args->data = p; | |
1888 uri->len -= len; | |
1889 | |
5491
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1890 break; |
573 | 1891 } |
1892 | |
1893 if (ch == '\0') { | |
3527 | 1894 goto unsafe; |
573 | 1895 } |
1896 | |
2744 | 1897 if (ngx_path_separator(ch) && len > 2) { |
1898 | |
5490
b141a7627ac6
Detect more unsafe URIs in ngx_http_parse_unsafe_uri().
Ruslan Ermilov <ru@nginx.com>
parents:
5442
diff
changeset
|
1899 /* detect "/../" and "/.." */ |
573 | 1900 |
5490
b141a7627ac6
Detect more unsafe URIs in ngx_http_parse_unsafe_uri().
Ruslan Ermilov <ru@nginx.com>
parents:
5442
diff
changeset
|
1901 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
|
1902 && (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
|
1903 { |
573 | 1904 goto unsafe; |
1905 } | |
1906 } | |
1907 } | |
1908 | |
5491
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1909 if (quoted) { |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1910 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
|
1911 "escaped URI: \"%V\"", uri); |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1912 |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1913 src = uri->data; |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1914 |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1915 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
|
1916 if (dst == NULL) { |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1917 return NGX_ERROR; |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1918 } |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1919 |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1920 uri->data = dst; |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1921 |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1922 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
|
1923 |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1924 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
|
1925 |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1926 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
|
1927 "unescaped URI: \"%V\"", uri); |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1928 |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1929 len = uri->len; |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1930 p = uri->data; |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1931 |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1932 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
|
1933 && (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
|
1934 { |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1935 goto unsafe; |
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 |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1938 for ( /* void */ ; len; len--) { |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1939 |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1940 ch = *p++; |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1941 |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1942 if (ch == '\0') { |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1943 goto unsafe; |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1944 } |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1945 |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1946 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
|
1947 |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1948 /* detect "/../" and "/.." */ |
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 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
|
1951 && (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
|
1952 { |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1953 goto unsafe; |
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 } |
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 } |
74bfa803a5aa
Teach ngx_http_parse_unsafe_uri() how to unescape URIs.
Ruslan Ermilov <ru@nginx.com>
parents:
5490
diff
changeset
|
1958 |
573 | 1959 return NGX_OK; |
1960 | |
1961 unsafe: | |
1962 | |
3161 | 1963 if (*flags & NGX_HTTP_LOG_UNSAFE) { |
1964 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1965 "unsafe URI \"%V\" was detected", uri); | |
1966 } | |
573 | 1967 |
1968 return NGX_ERROR; | |
1969 } | |
1970 | |
1971 | |
8024
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7884
diff
changeset
|
1972 ngx_table_elt_t * |
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7884
diff
changeset
|
1973 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
|
1974 ngx_table_elt_t *headers, ngx_str_t *name, ngx_str_t *value) |
509 | 1975 { |
8024
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7884
diff
changeset
|
1976 u_char *start, *last, *end, ch; |
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7884
diff
changeset
|
1977 ngx_table_elt_t *h; |
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7884
diff
changeset
|
1978 |
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7884
diff
changeset
|
1979 for (h = headers; h; h = h->next) { |
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7884
diff
changeset
|
1980 |
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7884
diff
changeset
|
1981 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
|
1982 "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
|
1983 |
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7884
diff
changeset
|
1984 if (name->len > h->value.len) { |
509 | 1985 continue; |
1986 } | |
577 | 1987 |
8024
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7884
diff
changeset
|
1988 start = h->value.data; |
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7884
diff
changeset
|
1989 end = h->value.data + h->value.len; |
509 | 1990 |
1991 while (start < end) { | |
1992 | |
1993 if (ngx_strncasecmp(start, name->data, name->len) != 0) { | |
1994 goto skip; | |
1995 } | |
1996 | |
1997 for (start += name->len; start < end && *start == ' '; start++) { | |
1998 /* void */ | |
1999 } | |
2000 | |
2001 if (value == NULL) { | |
2002 if (start == end || *start == ',') { | |
8024
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7884
diff
changeset
|
2003 return h; |
509 | 2004 } |
2005 | |
2006 goto skip; | |
2007 } | |
2008 | |
2009 if (start == end || *start++ != '=') { | |
2010 /* the invalid header value */ | |
2011 goto skip; | |
2012 } | |
2013 | |
2014 while (start < end && *start == ' ') { start++; } | |
2015 | |
2016 for (last = start; last < end && *last != ';'; last++) { | |
2017 /* void */ | |
2018 } | |
2019 | |
2020 value->len = last - start; | |
2021 value->data = start; | |
2022 | |
8024
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7884
diff
changeset
|
2023 return h; |
509 | 2024 |
2025 skip: | |
573 | 2026 |
509 | 2027 while (start < end) { |
2028 ch = *start++; | |
2029 if (ch == ';' || ch == ',') { | |
2030 break; | |
2031 } | |
2032 } | |
2033 | |
2034 while (start < end && *start == ' ') { start++; } | |
2035 } | |
2036 } | |
2037 | |
8024
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7884
diff
changeset
|
2038 return NULL; |
509 | 2039 } |
2415 | 2040 |
2041 | |
8024
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7884
diff
changeset
|
2042 ngx_table_elt_t * |
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7884
diff
changeset
|
2043 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
|
2044 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
|
2045 { |
8024
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7884
diff
changeset
|
2046 u_char *start, *last, *end; |
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7884
diff
changeset
|
2047 ngx_table_elt_t *h; |
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7884
diff
changeset
|
2048 |
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7884
diff
changeset
|
2049 for (h = headers; h; h = h->next) { |
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7884
diff
changeset
|
2050 |
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7884
diff
changeset
|
2051 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
|
2052 "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
|
2053 |
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7884
diff
changeset
|
2054 if (name->len >= h->value.len) { |
5677
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2055 continue; |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2056 } |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2057 |
8024
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7884
diff
changeset
|
2058 start = h->value.data; |
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7884
diff
changeset
|
2059 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
|
2060 |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2061 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
|
2062 continue; |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2063 } |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2064 |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2065 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
|
2066 /* void */ |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2067 } |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2068 |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2069 if (start == end || *start++ != '=') { |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2070 /* the invalid header value */ |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2071 continue; |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2072 } |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2073 |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2074 while (start < end && *start == ' ') { start++; } |
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 for (last = start; last < end && *last != ';'; last++) { |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2077 /* void */ |
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 value->len = last - start; |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2081 value->data = start; |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2082 |
8024
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7884
diff
changeset
|
2083 return h; |
5677
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2084 } |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2085 |
8024
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7884
diff
changeset
|
2086 return NULL; |
5677
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 |
3a48775f1535
Upstream: added the "$upstream_cookie_<name>" variables.
Vladimir Homutov <vl@nginx.com>
parents:
5624
diff
changeset
|
2090 ngx_int_t |
2415 | 2091 ngx_http_arg(ngx_http_request_t *r, u_char *name, size_t len, ngx_str_t *value) |
2092 { | |
2670
20a655d8a1f8
refactor ngx_http_arg() using ngx_strcasestrn(),
Igor Sysoev <igor@sysoev.ru>
parents:
2625
diff
changeset
|
2093 u_char *p, *last; |
2415 | 2094 |
2095 if (r->args.len == 0) { | |
2096 return NGX_DECLINED; | |
2097 } | |
2098 | |
2670
20a655d8a1f8
refactor ngx_http_arg() using ngx_strcasestrn(),
Igor Sysoev <igor@sysoev.ru>
parents:
2625
diff
changeset
|
2099 p = r->args.data; |
20a655d8a1f8
refactor ngx_http_arg() using ngx_strcasestrn(),
Igor Sysoev <igor@sysoev.ru>
parents:
2625
diff
changeset
|
2100 last = p + r->args.len; |
2415 | 2101 |
2670
20a655d8a1f8
refactor ngx_http_arg() using ngx_strcasestrn(),
Igor Sysoev <igor@sysoev.ru>
parents:
2625
diff
changeset
|
2102 for ( /* void */ ; p < last; p++) { |
2415 | 2103 |
2670
20a655d8a1f8
refactor ngx_http_arg() using ngx_strcasestrn(),
Igor Sysoev <igor@sysoev.ru>
parents:
2625
diff
changeset
|
2104 /* 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
|
2105 |
20a655d8a1f8
refactor ngx_http_arg() using ngx_strcasestrn(),
Igor Sysoev <igor@sysoev.ru>
parents:
2625
diff
changeset
|
2106 p = ngx_strlcasestrn(p, last - 1, name, len - 1); |
2415 | 2107 |
2108 if (p == NULL) { | |
2109 return NGX_DECLINED; | |
2110 } | |
2111 | |
2112 if ((p == r->args.data || *(p - 1) == '&') && *(p + len) == '=') { | |
2113 | |
2114 value->data = p + len + 1; | |
2115 | |
2670
20a655d8a1f8
refactor ngx_http_arg() using ngx_strcasestrn(),
Igor Sysoev <igor@sysoev.ru>
parents:
2625
diff
changeset
|
2116 p = ngx_strlchr(p, last, '&'); |
2415 | 2117 |
2118 if (p == NULL) { | |
2119 p = r->args.data + r->args.len; | |
2120 } | |
2121 | |
2122 value->len = p - value->data; | |
2123 | |
2124 return NGX_OK; | |
2125 } | |
2126 } | |
2127 | |
2128 return NGX_DECLINED; | |
2129 } | |
2578 | 2130 |
2131 | |
2132 void | |
2133 ngx_http_split_args(ngx_http_request_t *r, ngx_str_t *uri, ngx_str_t *args) | |
2134 { | |
3527 | 2135 u_char *p, *last; |
2578 | 2136 |
3527 | 2137 last = uri->data + uri->len; |
2625 | 2138 |
3527 | 2139 p = ngx_strlchr(uri->data, last, '?'); |
2578 | 2140 |
3527 | 2141 if (p) { |
2142 uri->len = p - uri->data; | |
2143 p++; | |
2144 args->len = last - p; | |
2145 args->data = p; | |
2578 | 2146 |
3527 | 2147 } else { |
2148 args->len = 0; | |
9278
f53146df9a47
Fixed Valgrind complaints about uninitialized values.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9267
diff
changeset
|
2149 args->data = NULL; |
2578 | 2150 } |
2151 } | |
4925
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2152 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2153 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2154 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
|
2155 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
|
2156 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
|
2157 { |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2158 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
|
2159 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
|
2160 enum { |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2161 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
|
2162 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
|
2163 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
|
2164 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
|
2165 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
|
2166 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
|
2167 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
|
2168 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
|
2169 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
|
2170 sw_trailer, |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2171 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
|
2172 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
|
2173 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
|
2174 } state; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2175 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2176 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
|
2177 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2178 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
|
2179 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
|
2180 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2181 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2182 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
|
2183 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2184 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
|
2185 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2186 ch = *pos; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2187 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2188 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
|
2189 "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
|
2190 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2191 switch (state) { |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2192 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2193 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
|
2194 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
|
2195 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
|
2196 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
|
2197 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2198 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2199 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2200 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
|
2201 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2202 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
|
2203 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
|
2204 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
|
2205 break; |
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 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2208 goto invalid; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2209 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2210 case sw_chunk_size: |
6014
e370c5fdf4c8
Overflow detection in ngx_http_parse_chunked().
Ruslan Ermilov <ru@nginx.com>
parents:
5757
diff
changeset
|
2211 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
|
2212 goto invalid; |
e370c5fdf4c8
Overflow detection in ngx_http_parse_chunked().
Ruslan Ermilov <ru@nginx.com>
parents:
5757
diff
changeset
|
2213 } |
e370c5fdf4c8
Overflow detection in ngx_http_parse_chunked().
Ruslan Ermilov <ru@nginx.com>
parents:
5757
diff
changeset
|
2214 |
4925
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2215 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
|
2216 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
|
2217 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2218 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2219 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2220 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
|
2221 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2222 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
|
2223 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
|
2224 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2225 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2226 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2227 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
|
2228 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2229 switch (ch) { |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2230 case CR: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2231 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
|
2232 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2233 case LF: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2234 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
|
2235 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2236 case ';': |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2237 case ' ': |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2238 case '\t': |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2239 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
|
2240 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2241 default: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2242 goto invalid; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2243 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2244 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2245 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2246 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2247 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2248 switch (ch) { |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2249 case CR: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2250 state = sw_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
|
2251 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2252 case LF: |
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_chunk_data; |
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 case ';': |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2256 case ' ': |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2257 case '\t': |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2258 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
|
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 default: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2261 goto invalid; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2262 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2263 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2264 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2265 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2266 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
|
2267 switch (ch) { |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2268 case CR: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2269 state = sw_chunk_extension_almost_done; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2270 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2271 case LF: |
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_data; |
9240
f3df785649ae
Request body: limited chunk extensions and trailer headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9187
diff
changeset
|
2273 break; |
f3df785649ae
Request body: limited chunk extensions and trailer headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9187
diff
changeset
|
2274 default: |
f3df785649ae
Request body: limited chunk extensions and trailer headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9187
diff
changeset
|
2275 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
|
2276 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2277 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2278 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2279 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
|
2280 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
|
2281 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
|
2282 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2283 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2284 goto invalid; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2285 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2286 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
|
2287 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
|
2288 goto data; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2289 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2290 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
|
2291 switch (ch) { |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2292 case CR: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2293 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
|
2294 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2295 case LF: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2296 state = sw_chunk_start; |
7562
52b5ee64fe11
Detect runaway chunks in ngx_http_parse_chunked().
Sergey Kandaurov <pluknet@nginx.com>
parents:
7292
diff
changeset
|
2297 break; |
52b5ee64fe11
Detect runaway chunks in ngx_http_parse_chunked().
Sergey Kandaurov <pluknet@nginx.com>
parents:
7292
diff
changeset
|
2298 default: |
52b5ee64fe11
Detect runaway chunks in ngx_http_parse_chunked().
Sergey Kandaurov <pluknet@nginx.com>
parents:
7292
diff
changeset
|
2299 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
|
2300 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2301 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2302 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2303 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
|
2304 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
|
2305 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
|
2306 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2307 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2308 goto invalid; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2309 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2310 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
|
2311 switch (ch) { |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2312 case CR: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2313 state = sw_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
|
2314 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2315 case LF: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2316 state = sw_trailer; |
9240
f3df785649ae
Request body: limited chunk extensions and trailer headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9187
diff
changeset
|
2317 break; |
f3df785649ae
Request body: limited chunk extensions and trailer headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9187
diff
changeset
|
2318 default: |
f3df785649ae
Request body: limited chunk extensions and trailer headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9187
diff
changeset
|
2319 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
|
2320 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2321 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2322 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2323 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
|
2324 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
|
2325 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
|
2326 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2327 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2328 goto invalid; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2329 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2330 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
|
2331 switch (ch) { |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2332 case CR: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2333 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
|
2334 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2335 case LF: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2336 goto done; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2337 default: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2338 state = sw_trailer_header; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2339 } |
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 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
|
2343 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
|
2344 goto done; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2345 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2346 goto invalid; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2347 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2348 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
|
2349 switch (ch) { |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2350 case CR: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2351 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
|
2352 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2353 case LF: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2354 state = sw_trailer; |
9240
f3df785649ae
Request body: limited chunk extensions and trailer headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9187
diff
changeset
|
2355 break; |
f3df785649ae
Request body: limited chunk extensions and trailer headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9187
diff
changeset
|
2356 default: |
f3df785649ae
Request body: limited chunk extensions and trailer headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9187
diff
changeset
|
2357 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
|
2358 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2359 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2360 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2361 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
|
2362 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
|
2363 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
|
2364 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2365 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2366 goto invalid; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2367 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2368 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2369 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2370 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2371 data: |
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 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
|
2374 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
|
2375 |
6014
e370c5fdf4c8
Overflow detection in ngx_http_parse_chunked().
Ruslan Ermilov <ru@nginx.com>
parents:
5757
diff
changeset
|
2376 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
|
2377 goto invalid; |
e370c5fdf4c8
Overflow detection in ngx_http_parse_chunked().
Ruslan Ermilov <ru@nginx.com>
parents:
5757
diff
changeset
|
2378 } |
e370c5fdf4c8
Overflow detection in ngx_http_parse_chunked().
Ruslan Ermilov <ru@nginx.com>
parents:
5757
diff
changeset
|
2379 |
4925
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2380 switch (state) { |
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 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
|
2383 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
|
2384 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2385 case sw_chunk_size: |
5256
b66ec10e901a
Fixed ngx_http_parse_chunked() minimal length calculation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5247
diff
changeset
|
2386 ctx->length = 1 /* LF */ |
b66ec10e901a
Fixed ngx_http_parse_chunked() minimal length calculation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5247
diff
changeset
|
2387 + (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
|
2388 : 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
|
2389 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2390 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
|
2391 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
|
2392 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
|
2393 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2394 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
|
2395 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
|
2396 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2397 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
|
2398 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
|
2399 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
|
2400 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2401 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
|
2402 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
|
2403 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
|
2404 break; |
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_trailer: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2406 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
|
2407 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
|
2408 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2409 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
|
2410 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
|
2411 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
|
2412 break; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2413 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2414 } |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2415 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2416 return rc; |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2417 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2418 done: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2419 |
4926
1c9d8b6523c0
Request body: adjust b->pos when chunked parsing done.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4925
diff
changeset
|
2420 ctx->state = 0; |
1c9d8b6523c0
Request body: adjust b->pos when chunked parsing done.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4925
diff
changeset
|
2421 b->pos = pos + 1; |
1c9d8b6523c0
Request body: adjust b->pos when chunked parsing done.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4925
diff
changeset
|
2422 |
4925
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2423 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
|
2424 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2425 invalid: |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2426 |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4674
diff
changeset
|
2427 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
|
2428 } |