HTTP-Tiny-SPDY

 view release on metacpan or  search on metacpan

t/http_tiny/100_get.t  view on Meta::CPAN

use File::Basename;
use Test::More 0.88;
use t::http_tiny::Util qw[tmpfile rewind slurp monkey_patch dir_list parse_case
  hashify connect_args set_socket_source sort_headers $CRLF $LF];

use HTTP::Tiny::SPDY;
BEGIN { monkey_patch() }

for my $file ( dir_list("t/http_tiny/cases", qr/^get/ ) ) {
  my $label = basename($file);
  my $data = do { local (@ARGV,$/) = $file; <> };
  my ($params, $expect_req, $give_res) = split /--+\n/, $data;
  my $case = parse_case($params);

  my $url = $case->{url}[0];
  my %headers = hashify( $case->{headers} );
  my %new_args = hashify( $case->{new_args} );

  my %options;
  $options{headers} = \%headers if %headers;
  if ( $case->{data_cb} ) {

t/http_tiny/101_head.t  view on Meta::CPAN

use warnings;

use File::Basename;
use Test::More 0.88;
use t::http_tiny::Util    qw[tmpfile rewind slurp monkey_patch dir_list parse_case
                  set_socket_source sort_headers $CRLF $LF];
use HTTP::Tiny::SPDY;
BEGIN { monkey_patch() }

for my $file ( dir_list("t/http_tiny/cases", qr/^head/ ) ) {
  my $data = do { local (@ARGV,$/) = $file; <> };
  my ($params, $expect_req, $give_res) = split /--+\n/, $data;
  # cleanup source data
  my $version = HTTP::Tiny::SPDY->VERSION || 0;
  $expect_req =~ s{VERSION}{$version};
  s{\n}{$CRLF}g for ($expect_req, $give_res);

  # figure out what request to make
  my $case = parse_case($params);
  my $url = $case->{url}[0];
  my %options;

t/http_tiny/102_put.t  view on Meta::CPAN

use warnings;

use File::Basename;
use Test::More 0.88;
use t::http_tiny::Util    qw[tmpfile rewind slurp monkey_patch dir_list parse_case
                  set_socket_source sort_headers $CRLF $LF];
use HTTP::Tiny::SPDY;
BEGIN { monkey_patch() }

for my $file ( dir_list("t/http_tiny/cases", qr/^put/ ) ) {
  my $data = do { local (@ARGV,$/) = $file; <> };
  my ($params, $expect_req, $give_res) = split /--+\n/, $data;
  # cleanup source data
  my $version = HTTP::Tiny::SPDY->VERSION || 0;
  $expect_req =~ s{VERSION}{$version};
  s{\n}{$CRLF}g for ($expect_req, $give_res);

  # figure out what request to make
  my $case = parse_case($params);
  my $url = $case->{url}[0];
  my %options;

t/http_tiny/103_delete.t  view on Meta::CPAN

use warnings;

use File::Basename;
use Test::More 0.88;
use t::http_tiny::Util    qw[tmpfile rewind slurp monkey_patch dir_list parse_case
                  set_socket_source sort_headers $CRLF $LF];
use HTTP::Tiny::SPDY;
BEGIN { monkey_patch() }

for my $file ( dir_list("t/http_tiny/cases", qr/^delete/ ) ) {
  my $data = do { local (@ARGV,$/) = $file; <> };
  my ($params, $expect_req, $give_res) = split /--+\n/, $data;
  # cleanup source data
  my $version = HTTP::Tiny::SPDY->VERSION || 0;
  $expect_req =~ s{VERSION}{$version};
  s{\n}{$CRLF}g for ($expect_req, $give_res);

  # figure out what request to make
  my $case = parse_case($params);
  my $url = $case->{url}[0];
  my %options;

t/http_tiny/104_post.t  view on Meta::CPAN

use warnings;

use File::Basename;
use Test::More 0.88;
use t::http_tiny::Util    qw[tmpfile rewind slurp monkey_patch dir_list parse_case
                  set_socket_source sort_headers $CRLF $LF];
use HTTP::Tiny::SPDY;
BEGIN { monkey_patch() }

for my $file ( dir_list("t/http_tiny/cases", qr/^post/ ) ) {
  my $data = do { local (@ARGV,$/) = $file; <> };
  my ($params, $expect_req, $give_res) = split /--+\n/, $data;
  # cleanup source data
  my $version = HTTP::Tiny::SPDY->VERSION || 0;
  $expect_req =~ s{VERSION}{$version};
  s{\n}{$CRLF}g for ($expect_req, $give_res);

  # figure out what request to make
  my $case = parse_case($params);
  my $url = $case->{url}[0];
  my %options;

t/http_tiny/110_mirror.t  view on Meta::CPAN

my $known_epoch = 760233600;
my $day = 24*3600;

my %timestamp = (
  'modified.txt'      => $known_epoch - 2 * $day,
  'not-modified.txt'  => $known_epoch - 2 * $day,
);

for my $file ( dir_list("t/http_tiny/cases", qr/^mirror/ ) ) {
  1 while unlink $tempfile;
  my $data = do { local (@ARGV,$/) = $file; <> };
  my ($params, $expect_req, $give_res) = split /--+\n/, $data;
  # cleanup source data
  my $version = HTTP::Tiny::SPDY->VERSION || 0;
  $expect_req =~ s{VERSION}{$version};
  s{\n}{$CRLF}g for ($expect_req, $give_res);

  # figure out what request to make
  my $case = parse_case($params);
  my $url = $case->{url}->[0];
  my %options;

t/http_tiny/130_redirect.t  view on Meta::CPAN

use Test::More 0.88;
use t::http_tiny::Util qw[tmpfile rewind slurp monkey_patch dir_list parse_case
  hashify connect_args clear_socket_source set_socket_source sort_headers
  $CRLF $LF];

use HTTP::Tiny::SPDY;
BEGIN { monkey_patch() }

for my $file ( dir_list("t/http_tiny/cases", qr/^redirect/ ) ) {
  my $label = basename($file);
  my $data = do { local (@ARGV,$/) = $file; <> };
  my ($params, @case_pairs) = split /--+\n/, $data;
  my $case = parse_case($params);

  my $url = $case->{url}[0];
  my $method = $case->{method}[0] || 'GET';
  my %headers = hashify( $case->{headers} );
  my %new_args = hashify( $case->{new_args} );

  my %options;
  $options{headers} = \%headers if %headers;

t/http_tiny/150_post_form.t  view on Meta::CPAN

use open IN => ':raw';

use File::Basename;
use Test::More 0.88;
use t::http_tiny::Util    qw[tmpfile rewind slurp monkey_patch dir_list parse_case
                  set_socket_source sort_headers $CRLF $LF];
use HTTP::Tiny::SPDY;
BEGIN { monkey_patch() }

for my $file ( dir_list("t/http_tiny/cases", qr/^form/ ) ) {
  my $data = do { local (@ARGV,$/) = $file; <> };
  my ($params, $expect_req, $give_res) = split /--+\n/, $data;
  # cleanup source data
  my $version = HTTP::Tiny::SPDY->VERSION || 0;
  $expect_req =~ s{VERSION}{$version};
  s{\n}{$CRLF}g for ($expect_req, $give_res);

  # figure out what request to make
  my $case = parse_case($params);
  my $url = $case->{url}[0];
  my %options;

t/http_tiny/160_cookies.t  view on Meta::CPAN

BEGIN { monkey_patch() }

SKIP: for my $class ( qw/t::SimpleCookieJar HTTP::CookieJar/ ) {

    subtest $class => sub {
        eval "require $class; 1"
            or plan skip_all => "Needs $class";

        for my $file ( dir_list("t/http_tiny/cases", qr/^cookies/ ) ) {
            my $label = basename($file);
            my $data = do { local (@ARGV,$/) = $file; <> };
            my @cases = split /--+\n/, $data;

            my $jar = t::http_tiny::SimpleCookieJar->new();
            my $http = undef;
            while (@cases) {
                my ($params, $expect_req, $give_res) = splice( @cases, 0, 3 );

                my $case = parse_case($params);

                my $url = $case->{url}[0];

t/http_tiny/161_basic_auth.t  view on Meta::CPAN

use Test::More 0.88;
use t::http_tiny::Util qw[tmpfile rewind slurp monkey_patch dir_list parse_case
  hashify connect_args clear_socket_source set_socket_source sort_headers
  $CRLF $LF];

use HTTP::Tiny::SPDY;
BEGIN { monkey_patch() }

for my $file ( dir_list("t/http_tiny/cases", qr/^auth/ ) ) {
  my $label = basename($file);
  my $data = do { local (@ARGV,$/) = $file; <> };
  my ($params, @case_pairs) = split /--+\n/, $data;
  my $case = parse_case($params);

  my $url = $case->{url}[0];
  my $method = $case->{method}[0] || 'GET';
  my %headers = hashify( $case->{headers} );
  my %new_args = hashify( $case->{new_args} );

  my %options;
  $options{headers} = \%headers if %headers;

t/http_tiny/162_proxy_auth.t  view on Meta::CPAN

use Test::More 0.88;
use t::http_tiny::Util qw[tmpfile rewind slurp monkey_patch dir_list parse_case
  hashify connect_args clear_socket_source set_socket_source sort_headers
  $CRLF $LF];

use HTTP::Tiny::SPDY;
BEGIN { monkey_patch() }

for my $file ( dir_list("t/http_tiny/cases", qr/^proxy-auth/ ) ) {
  my $label = basename($file);
  my $data = do { local (@ARGV,$/) = $file; <> };
  my ($params, @case_pairs) = split /--+\n/, $data;
  my $case = parse_case($params);

  my $url = $case->{url}[0];
  my $method = $case->{method}[0] || 'GET';
  my %headers = hashify( $case->{headers} );
  my %new_args = hashify( $case->{new_args} );

  my %options;
  $options{headers} = \%headers if %headers;

t/http_tiny/170_keepalive.t  view on Meta::CPAN

new_ht();
$h->default_headers({ 'X-Foo' => 'Bar' });
test_ht( "Default headers change", 1, 'http://foo.com' );

new_ht();
$h->{handle}->close;
test_ht( "Socket closed", 0, 'http://foo.com' );

for my $file ( dir_list( "t/http_tiny/cases", qr/^keepalive/ ) ) {
    my $label = basename($file);
    my $data = do { local ( @ARGV, $/ ) = $file; <> };
    my ( $title, $ok, $response ) = map { trim($_) } split /--+/, $data;
    new_ht();
    clear_socket_source();
    set_socket_source( tmpfile(), tmpfile($response) );
    $h->request( 'POST', 'http://foo.com', { content => 'xx' } );
    is !!$h->{handle}, !!$ok, "$label - $title";
}

sub test_ht {
    my $title  = shift;

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 1.169 second using v1.00-cache-2.02-grep-82fe00e-cpan-c9a218a2bbc )