HTTP-Request-FromCurl
view release on metacpan or search on metacpan
t/TestCurlIdentity.pm view on Meta::CPAN
my $h = $test->{ignore_headers} || [];
$h = [$h]
unless ref $h;
identical_headers_ok( $code, $curl_log,
"We create (almost) the same headers with LWP",
ignore_headers => ['Connection', @lwp_ignore, @$h],
boundary => $boundary,
) or diag $code;
$code = $r->as_snippet(type => 'Tiny',
preamble => ['use strict;','use HTTP::Tiny;']
);
compiles_ok( $code, "$name as HTTP::Tiny snippet compiles OK")
or diag $code;
identical_headers_ok( $code, $curl_log,
"We create (almost) the same headers with HTTP::Tiny",
ignore_headers => ['Host','Connection', @$h],
boundary => $boundary,
) or diag $code;
if( $have_mojolicious ) {
my $code = $r->as_snippet(type => 'Mojolicious',
preamble => ['use strict;','use Mojo::UserAgent;']
);
compiles_ok( $code, "$name as Mojolicious snippet compiles OK")
or diag $code;
my @mojolicious_ignore;
my $h = $test->{ignore_headers} || [];
$h = [$h]
unless ref $h;
identical_headers_ok( $code, $curl_log,
"We create (almost) the same headers with Mojolicious",
ignore_headers => ['Host', 'Content-Length', 'Accept-Encoding', 'Connection', @mojolicious_ignore, @$h],
boundary => $boundary,
) or diag $code;
} else {
SKIP: {
skip "Mojolicious not installed", 2;
}
}
} else {
SKIP: {
skip "Did not generate a request", 6;
};
};
};
};
sub run_curl_tests( @tests ) {
my $testcount = 0;
# Clean out environment variables that might mess up
# the HTTP connection to a local host
local @ENV{qw(
HTTP_PROXY
http_proxy
HTTP_PROXY_ALL
http_proxy_all
HTTPS_PROXY
https_proxy
CGI_HTTP_PROXY
ALL_PROXY
all_proxy
)};
for( @tests ) {
my $request_count = $_->{request_count} || 1;
$testcount += 2
+ ($request_count * 8);
};
plan tests => $testcount;
diag "Testing with curl version '$version'";
for my $test ( @tests ) {
request_identical_ok( $test );
};
done_testing();
};
( run in 0.729 second using v1.01-cache-2.11-cpan-71847e10f99 )