comparison proxy-noclose.t @ 23:e6b7c3b5389c

Tests: test for multiple buffers in proxy-noclose.t.
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 29 Sep 2008 02:10:07 +0400
parents 5e65db715827
children fbda19df2fc4
comparison
equal deleted inserted replaced
22:5e65db715827 23:e6b7c3b5389c
9 ############################################################################### 9 ###############################################################################
10 10
11 use warnings; 11 use warnings;
12 use strict; 12 use strict;
13 13
14 use Test::More tests => 1; 14 use Test::More tests => 2;
15
16 use IO::Select;
15 17
16 BEGIN { use FindBin; chdir($FindBin::Bin); } 18 BEGIN { use FindBin; chdir($FindBin::Bin); }
17 19
18 use lib 'lib'; 20 use lib 'lib';
19 use Test::Nginx; 21 use Test::Nginx;
57 ############################################################################### 59 ###############################################################################
58 60
59 TODO: { 61 TODO: {
60 local $TODO = 'not fixed yet, submit patches'; 62 local $TODO = 'not fixed yet, submit patches';
61 63
62 my $t1 = http_request('/'); 64 like(http_request('/'), qr/TEST-OK-IF-YOU-SEE-THIS/, 'request to bad backend');
63 like($t1, qr/TEST-OK-IF-YOU-SEE-THIS/, 'request to bad backend'); 65 like(http_request('/multi'), qr/AND-THIS/, 'bad backend - multiple packets');
64 66
65 } 67 }
66 68
67 ############################################################################### 69 ###############################################################################
68 70
86 or die "Can't create listening socket: $!\n"; 88 or die "Can't create listening socket: $!\n";
87 89
88 while (my $client = $server->accept()) { 90 while (my $client = $server->accept()) {
89 $client->autoflush(1); 91 $client->autoflush(1);
90 92
93 my $multi = 0;
94
91 while (<$client>) { 95 while (<$client>) {
96 $multi = 1 if /multi/;
92 last if (/^\x0d?\x0a?$/); 97 last if (/^\x0d?\x0a?$/);
93 } 98 }
94 99
95 print $client <<'EOF'; 100 my $length = $multi ? 32 : 24;
101
102 print $client <<"EOF";
96 HTTP/1.1 200 OK 103 HTTP/1.1 200 OK
97 Content-Length: 24 104 Content-Length: $length
98 Connection: close 105 Connection: close
99 106
100 TEST-OK-IF-YOU-SEE-THIS 107 TEST-OK-IF-YOU-SEE-THIS
101 EOF 108 EOF
102 sleep 2; 109
110 if ($multi) {
111 select undef, undef, undef, 0.1;
112 print $client 'AND-THIS';
113 }
114
115 my $select = IO::Select->new($client);
116 $select->can_read(2);
103 close $client; 117 close $client;
104 } 118 }
105 } 119 }
106 120
107 ############################################################################### 121 ###############################################################################