@@ -18,7 +18,7 @@ my $BASE_URL;
1818my @TESTS = get_tests();
1919
2020for my $test (@TESTS ) {
21-
21+
2222 my $http_daemon = HTTP::Daemon-> new() or die " HTTP::Daemon->new: $! " ;
2323 $BASE_URL = $http_daemon -> url;
2424
@@ -27,18 +27,18 @@ for my $test (@TESTS) {
2727 if ($pid == 0) {
2828 accept_requests($http_daemon );
2929 }
30-
30+
3131 my $resp = http_test_request($test );
32-
32+
3333 ok $resp , $test -> {title };
34-
34+
3535 is $resp -> {status }, $test -> {status },
3636 " ... and has expected status" ;
37-
37+
3838 like $resp -> {content }, $test -> {like },
3939 " ... and body does match"
4040 if $test -> {like };
41-
41+
4242}
4343
4444done_testing;
@@ -150,16 +150,16 @@ sub router_table {
150150 return $resp ;
151151 },
152152 },
153-
153+
154154 ' /' => {
155155 ' POST' => sub {
156156 my $rqst = shift ;
157-
157+
158158 my $body = $rqst -> content();
159-
159+
160160 my $resp = HTTP::Response-> new(200);
161161 $resp -> content($body );
162-
162+
163163 return $resp
164164 },
165165 },
@@ -240,39 +240,39 @@ sub http_test_request {
240240
241241
242242sub patch_http_tiny {
243-
243+
244244 # we need to patch write_content_body
245245 # this is part of HTTP::Tiny internal module HTTP::Tiny::Handle
246246 #
247247 # the below code is from the original HTTP::Tiny module, where just two lines
248248 # have been commented out
249-
249+
250250 no strict ' refs' ;
251-
251+
252252 *HTTP::Tiny::Handle::write_content_body = sub {
253253 @_ == 2 || die (q/ Usage: $handle->write_content_body(request)/ . " \n " );
254254 my ($self , $request ) = @_ ;
255-
255+
256256 my ($len , $content_length ) = (0, $request -> {headers }{' content-length' });
257257 while () {
258258 my $data = $request -> {cb }-> ();
259-
259+
260260 defined $data && length $data
261261 or last ;
262-
262+
263263 if ( $] ge ' 5.008' ) {
264264 utf8::downgrade($data , 1)
265265 or die (qq/ Wide character in write_content()\n / );
266266 }
267-
267+
268268 $len += $self -> write ($data );
269269 }
270-
270+
271271# this should not be checked during our tests, we want to forge bad requests
272- #
272+ #
273273# $len == $content_length
274274# or die(qq/Content-Length mismatch (got: $len expected: $content_length)\n/);
275-
275+
276276 return $len ;
277277 };
278278}
0 commit comments