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