WWW-Mechanize

 view release on metacpan or  search on metacpan

t/cookies.t  view on Meta::CPAN

# XXX add cookie reading on the server side to the test

BEGIN { delete @ENV{qw( http_proxy HTTP_PROXY )}; }

use warnings;
use strict;
use Test::More;

if ( $^O =~ /Win32/ ) {
    plan skip_all => 'HTTP::Server::Simple does not support Windows yet.';
}
else {
    plan tests => 14;
}

use WWW::Mechanize ();
use URI::Escape    qw( uri_escape uri_unescape );

use lib 't/';
use TestServer ();

my $ncookies = 0;

sub send_cookies {
    my $req = shift;

    ++$ncookies;
    my $cvalue = uri_escape("Cookie #$ncookies");

    HTTP::Response->new(
        200, 'OK',
        [
            'Content-Type' => 'text/html',
            'Set-Cookie'   =>
                "my_cookie=$cvalue; Path=/; Domain=127.0.0.1; Expires=+1h;",
        ],
        <<"END_HTML",
<html>
<head>
    <title>Home of Cookie #$ncookies</title>
</head>
<body>
    <h1>Here is Cookie #$ncookies</h1>
</body>
</html>
END_HTML
    );
}

sub nosend_cookies {
    HTTP::Response->new(
        200, 'OK',
        [ 'Content-Type' => 'text/html' ],
        <<"END_HTML",
<html>
<head>
    <title>No cookies sent</title>
</head>
<body>
    <h1>No cookies sent</h1>
</body>
</html>
END_HTML



( run in 0.862 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )