"Fossies" - the Fresh Open Source Software Archive

Member "libwww-perl-6.43/xt/author/live/jigsaw/chunk.t" (26 Nov 2019, 1065 Bytes) of package /linux/www/libwww-perl-6.43.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 use strict;
    2 use warnings;
    3 use Test::More;
    4 use Test::RequiresInternet ('jigsaw.w3.org' => 80);
    5 
    6 use HTTP::Request;
    7 use LWP::UserAgent;
    8 
    9 plan tests => 8;
   10 
   11 my $ua = LWP::UserAgent->new(keep_alive => 1);
   12 
   13 my $req = HTTP::Request->new(GET => "http://jigsaw.w3.org/HTTP/ChunkedScript");
   14 my $res = $ua->request($req);
   15 isa_ok($res, 'HTTP::Response', 'request: Got a proper response');
   16 
   17 ok($res->is_success, 'response success');
   18 is($res->content_type, 'text/plain', 'Content-Type: text/plain');
   19 is($res->header('Client-Transfer-Encoding'), "chunked", 'Client-Transfer-Encoding: chunked');
   20 
   21 for my $cref ( ${$res->content_ref} ) {
   22     $cref =~ s/\015?\012/\n/g;
   23     like($cref, qr/Below this line, is 1000 repeated lines of 0-9/, 'proper text found');
   24     $cref =~ s/^.*?-----+\n//s;
   25 
   26     my @lines = split(/^/, $cref);
   27     is(scalar(@lines), 1000, 'Got 1000 lines');
   28 
   29     # check that all lines are the same
   30     my $first = shift(@lines);
   31     like($first, qr/^\d+$/, 'The first line is a number');
   32 
   33     is(scalar(grep {$_ ne $first} @lines), 0, 'All lines are the same');
   34 }