Mercurial > hg > nginx-tests
annotate scgi_extra_data.t @ 1990:85d88cd5091c
Tests: SSI include stub tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 04 Jul 2024 17:42:55 +0300 |
parents | 5ac6efbe5552 |
children |
rev | line source |
---|---|
1581
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
2 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
3 # (C) Maxim Dounin |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
5 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
6 # Test for scgi backend with extra data. |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
7 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
8 ############################################################################### |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
9 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
10 use warnings; |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
11 use strict; |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
12 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
13 use Test::More; |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
14 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
16 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
17 use lib 'lib'; |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
18 use Test::Nginx; |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
19 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
20 ############################################################################### |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
21 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
22 select STDERR; $| = 1; |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
23 select STDOUT; $| = 1; |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
24 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
25 eval { require SCGI; }; |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
26 plan(skip_all => 'SCGI not installed') if $@; |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
27 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
28 my $t = Test::Nginx->new() |
1638
6128590b0d46
Tests: tests for "zero size buf" alerts in unbuffered proxying.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1581
diff
changeset
|
29 ->has(qw/http scgi cache rewrite addition/)->plan(22) |
1581
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
30 ->write_file_expand('nginx.conf', <<'EOF'); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
31 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
32 %%TEST_GLOBALS%% |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
33 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
34 daemon off; |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
35 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
36 events { |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
37 } |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
38 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
39 http { |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
40 %%TEST_GLOBALS_HTTP%% |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
41 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
42 scgi_param SCGI 1; |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
43 scgi_param REQUEST_URI $request_uri; |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
44 scgi_param REQUEST_METHOD $request_method; |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
45 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
46 scgi_cache_path cache keys_zone=one:1m; |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
47 scgi_cache_key $request_uri; |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
48 scgi_cache_valid any 1m; |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
49 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
50 server { |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
51 listen 127.0.0.1:8080; |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
52 server_name localhost; |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
53 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
54 location / { |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
55 scgi_pass 127.0.0.1:8081; |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
56 add_after_body /after; |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
57 } |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
58 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
59 location /unbuf/ { |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
60 scgi_pass 127.0.0.1:8081; |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
61 scgi_buffering off; |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
62 add_after_body /after; |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
63 } |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
64 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
65 location /head/ { |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
66 scgi_pass 127.0.0.1:8081; |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
67 scgi_cache one; |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
68 add_after_body /after; |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
69 } |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
70 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
71 location /after { |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
72 return 200 ":after\n"; |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
73 } |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
74 } |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
75 } |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
76 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
77 EOF |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
78 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
79 $t->run_daemon(\&scgi_daemon); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
80 $t->run()->waitforsocket('127.0.0.1:' . port(8081)); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
81 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
82 ############################################################################### |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
83 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
84 like(http_get('/'), qr/SEE-THIS(?!-BUT-NOT-THIS)/, 'response with extra data'); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
85 like(http_get('/short'), qr/SEE-THIS(?!.*:after)/s, 'too short response'); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
86 like(http_get('/empty'), qr/200 OK(?!.*:after)/s, 'empty too short response'); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
87 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
88 like(http_head('/'), qr/200 OK(?!.*SEE-THIS)/s, 'no data in HEAD'); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
89 like(http_head('/short'), qr/200 OK(?!.*SEE-THIS)/s, 'too short to HEAD'); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
90 like(http_head('/empty'), qr/200 OK/, 'empty response to HEAD'); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
91 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
92 # unbuffered responses |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
93 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
94 like(http_get('/unbuf/'), qr/SEE-THIS(?!-BUT-NOT-THIS)/, |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
95 'unbuffered with extra data'); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
96 like(http_get('/unbuf/short'), qr/SEE-THIS(?!.*:after)/s, |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
97 'unbuffered too short response'); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
98 like(http_get('/unbuf/empty'), qr/200 OK(?!.*:after)/s, |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
99 'unbuffered empty too short response'); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
100 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
101 like(http_head('/unbuf/'), qr/200 OK(?!.*SEE-THIS)/s, |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
102 'unbuffered no data in HEAD'); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
103 like(http_head('/unbuf/short'), qr/200 OK(?!.*SEE-THIS)/s, |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
104 'unbuffered too short response to HEAD'); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
105 like(http_head('/unbuf/empty'), qr/200 OK/, |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
106 'unbuffered empty response to HEAD'); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
107 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
108 # caching of responsses to HEAD requests |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
109 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
110 like(http_head('/head/empty'), qr/200 OK(?!.*SEE-THIS)/s, 'head no body'); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
111 like(http_head('/head/matching'), qr/200 OK(?!.*SEE-THIS)/s, 'head matching'); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
112 like(http_head('/head/extra'), qr/200 OK(?!.*SEE-THIS)/s, 'head extra'); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
113 like(http_head('/head/short'), qr/200 OK(?!.*SEE-THIS)/s, 'head too short'); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
114 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
115 like(http_get('/head/empty'), qr/SEE-THIS/, 'head no body cached'); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
116 like(http_get('/head/matching'), qr/SEE-THIS/, 'head matching cached'); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
117 like(http_get('/head/extra'), qr/SEE-THIS(?!-BUT-NOT-THIS)/s, |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
118 'head extra cached'); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
119 like(http_get('/head/short'), qr/SEE-THIS(?!.*:after)/s, |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
120 'head too short cached'); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
121 |
1638
6128590b0d46
Tests: tests for "zero size buf" alerts in unbuffered proxying.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1581
diff
changeset
|
122 # "zero size buf" alerts (ticket #2117) |
6128590b0d46
Tests: tests for "zero size buf" alerts in unbuffered proxying.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1581
diff
changeset
|
123 |
6128590b0d46
Tests: tests for "zero size buf" alerts in unbuffered proxying.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1581
diff
changeset
|
124 like(http_get('/zero'), qr/200 OK(?!.*NOT-THIS)/s, 'zero size'); |
6128590b0d46
Tests: tests for "zero size buf" alerts in unbuffered proxying.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1581
diff
changeset
|
125 like(http_get('/unbuf/zero'), qr/200 OK(?!.*NOT-THIS)/s, |
6128590b0d46
Tests: tests for "zero size buf" alerts in unbuffered proxying.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1581
diff
changeset
|
126 'unbuffered zero size'); |
6128590b0d46
Tests: tests for "zero size buf" alerts in unbuffered proxying.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1581
diff
changeset
|
127 |
1581
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
128 ############################################################################### |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
129 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
130 sub scgi_daemon { |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
131 my $server = IO::Socket::INET->new( |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
132 Proto => 'tcp', |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
133 LocalHost => '127.0.0.1:' . port(8081), |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
134 Listen => 5, |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
135 Reuse => 1 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
136 ) |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
137 or die "Can't create listening socket: $!\n"; |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
138 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
139 my $scgi = SCGI->new($server, blocking => 1); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
140 my ($c, $uri, $head); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
141 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
142 while (my $request = $scgi->accept()) { |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
143 eval { $request->read_env(); }; |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
144 next if $@; |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
145 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
146 $uri = $request->env->{REQUEST_URI}; |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
147 $uri =~ s!^/unbuf!!; |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
148 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
149 $head = $request->env->{REQUEST_METHOD} eq 'HEAD'; |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
150 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
151 $c = $request->connection(); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
152 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
153 if ($uri eq '/') { |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
154 $c->print("Content-Type: text/html\n"); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
155 $c->print("Content-Length: 8\n\n"); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
156 $c->print("SEE-THIS-BUT-NOT-THIS\n"); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
157 |
1638
6128590b0d46
Tests: tests for "zero size buf" alerts in unbuffered proxying.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1581
diff
changeset
|
158 } elsif ($uri eq '/zero') { |
6128590b0d46
Tests: tests for "zero size buf" alerts in unbuffered proxying.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1581
diff
changeset
|
159 $c->print("Content-Type: text/html\n"); |
6128590b0d46
Tests: tests for "zero size buf" alerts in unbuffered proxying.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1581
diff
changeset
|
160 $c->print("Content-Length: 0\n\n"); |
6128590b0d46
Tests: tests for "zero size buf" alerts in unbuffered proxying.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1581
diff
changeset
|
161 $c->print("NOT-THIS\n"); |
6128590b0d46
Tests: tests for "zero size buf" alerts in unbuffered proxying.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1581
diff
changeset
|
162 |
1581
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
163 } elsif ($uri eq '/short') { |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
164 $c->print("Content-Type: text/html\n"); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
165 $c->print("Content-Length: 100\n\n"); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
166 $c->print("SEE-THIS-TOO-SHORT-RESPONSE\n"); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
167 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
168 } elsif ($uri eq '/empty') { |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
169 $c->print("Content-Type: text/html\n"); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
170 $c->print("Content-Length: 100\n\n"); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
171 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
172 } elsif ($uri eq '/head/empty') { |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
173 $c->print("Content-Type: text/html\n"); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
174 $c->print("Content-Length: 8\n\n"); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
175 $c->print("SEE-THIS") unless $head; |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
176 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
177 } elsif ($uri eq '/head/matching') { |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
178 $c->print("Content-Type: text/html\n"); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
179 $c->print("Content-Length: 8\n\n"); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
180 $c->print("SEE-THIS"); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
181 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
182 } elsif ($uri eq '/head/extra') { |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
183 $c->print("Content-Type: text/html\n"); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
184 $c->print("Content-Length: 8\n\n"); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
185 $c->print("SEE-THIS-BUT-NOT-THIS\n"); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
186 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
187 } elsif ($uri eq '/head/short') { |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
188 $c->print("Content-Type: text/html\n"); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
189 $c->print("Content-Length: 100\n\n"); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
190 $c->print("SEE-THIS\n"); |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
191 } |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
192 } |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
193 } |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
194 |
463d6863d360
Tests: tests for extra data and short responses.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
195 ############################################################################### |