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