"Fossies" - the Fresh Open Source Software Archive

Member "libwww-perl-6.43/xt/author/live/jigsaw/md5-get.t" (26 Nov 2019, 847 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 Digest::MD5 qw(md5_base64);
    7 use HTTP::Request;
    8 use LWP::UserAgent;
    9 
   10 plan tests => 5;
   11 
   12 my $ua = LWP::UserAgent->new(keep_alive => 1);
   13 
   14 my $res = $ua->get(
   15     "http://jigsaw.w3.org/HTTP/h-content-md5.html",
   16     "TE" => "deflate",
   17 );
   18 isa_ok($res, 'HTTP::Response', 'request: Got a proper response');
   19 is($res->header('Content-MD5'), md5_base64($res->content).'==', 'Content-MD5 header matches content');
   20 
   21 my $etag = $res->header("etag");
   22 $res = $ua->get(
   23     "http://jigsaw.w3.org/HTTP/h-content-md5.html",
   24     "TE" => "deflate",
   25     "If-None-Match" => $etag,
   26 );
   27 isa_ok($res, 'HTTP::Response', 'request: Got a proper response');
   28 is($res->code, 304, 'response code: 304');
   29 is($res->header('Client-Response-Num'), 2, 'Client-Response-Num header is 2');