comparison proxy-noclose.t @ 83:6e5884419e4a

Tests: whitespace cleanup.
author Maxim Dounin <mdounin@mdounin.ru>
date Sun, 12 Apr 2009 06:46:21 +0400
parents 24143894b91b
children 1c0ec30614c6
comparison
equal deleted inserted replaced
82:a2fc9b9e9a2b 83:6e5884419e4a
90 90
91 ############################################################################### 91 ###############################################################################
92 92
93 sub http_noclose_daemon { 93 sub http_noclose_daemon {
94 my $server = IO::Socket::INET->new( 94 my $server = IO::Socket::INET->new(
95 Proto => 'tcp', 95 Proto => 'tcp',
96 LocalAddr => '127.0.0.1:8081', 96 LocalAddr => '127.0.0.1:8081',
97 Listen => 5, 97 Listen => 5,
98 Reuse => 1 98 Reuse => 1
99 ) 99 )
100 or die "Can't create listening socket: $!\n"; 100 or die "Can't create listening socket: $!\n";
101 101
102 while (my $client = $server->accept()) { 102 while (my $client = $server->accept()) {
103 $client->autoflush(1); 103 $client->autoflush(1);
104 104
105 my $multi = 0; 105 my $multi = 0;
106 my $nolen = 0; 106 my $nolen = 0;
107 107
108 while (<$client>) { 108 while (<$client>) {
109 $multi = 1 if /multi/; 109 $multi = 1 if /multi/;
110 $nolen = 1 if /nolen/; 110 $nolen = 1 if /nolen/;
111 last if (/^\x0d?\x0a?$/); 111 last if (/^\x0d?\x0a?$/);
112 } 112 }
113 113
114 if ($nolen) { 114 if ($nolen) {
115 115
116 print $client <<'EOF'; 116 print $client <<'EOF';
117 HTTP/1.1 200 OK 117 HTTP/1.1 200 OK
119 119
120 TEST-OK-IF-YOU-SEE-THIS 120 TEST-OK-IF-YOU-SEE-THIS
121 EOF 121 EOF
122 } elsif ($multi) { 122 } elsif ($multi) {
123 123
124 print $client <<"EOF"; 124 print $client <<"EOF";
125 HTTP/1.1 200 OK 125 HTTP/1.1 200 OK
126 Content-Length: 32 126 Content-Length: 32
127 Connection: close 127 Connection: close
128 128
129 TEST-OK-IF-YOU-SEE-THIS 129 TEST-OK-IF-YOU-SEE-THIS
132 select undef, undef, undef, 0.1; 132 select undef, undef, undef, 0.1;
133 print $client 'AND-THIS'; 133 print $client 'AND-THIS';
134 134
135 } else { 135 } else {
136 136
137 print $client <<"EOF"; 137 print $client <<"EOF";
138 HTTP/1.1 200 OK 138 HTTP/1.1 200 OK
139 Content-Length: 24 139 Content-Length: 24
140 Connection: close 140 Connection: close
141 141
142 TEST-OK-IF-YOU-SEE-THIS 142 TEST-OK-IF-YOU-SEE-THIS
143 EOF 143 EOF
144 } 144 }
145 145
146 my $select = IO::Select->new($client); 146 my $select = IO::Select->new($client);
147 $select->can_read(10); 147 $select->can_read(10);
148 close $client; 148 close $client;
149 } 149 }
150 } 150 }
151 151
152 ############################################################################### 152 ###############################################################################