Net-Async-HTTP
view release on metacpan or search on metacpan
examples/PUT.pl view on Meta::CPAN
my $uri = URI->new($url) or die "Invalid URL?\n";
my $req = HTTP::Request->new(
PUT => $uri->path, [
'Host' => $uri->host,
'Content-Type' => $contenttype,
]
);
# Default is no protocol, we insist on HTTP/1.1 here, PUT probably requires that as a minimum anyway
$req->protocol( 'HTTP/1.1' );
$req->authorization_basic( split m/:/, $userpass, 2 ) if defined $userpass;
$req->content_length( $size );
# For stats
my $total = 0;
my $last = -1;
my $start;
$ua->do_request(
request => $req,
host => $uri->host,
t/18content-coding.t view on Meta::CPAN
skip "Compress::Raw::Zlib not available", 4 unless eval { require Compress::Raw::Zlib and $Compress::Raw::Zlib::VERSION >= 2.057 };
diag( "Using optional dependency Compress::Raw::Zlib $Compress::Raw::Zlib::VERSION" );
my $f = $http->GET( "http://host/gzip" );
$f->on_fail( sub { $f->get } );
{
my $request_stream = "";
wait_for_stream { $request_stream =~ m/$CRLF$CRLF/ } $peersock => $request_stream;
my ( undef, @headers ) = split m/$CRLF/, $request_stream;
ok( scalar( grep { m/^Accept-Encoding: / } @headers ), 'Request as an Accept-Encoding header' );
my $compressor = Compress::Raw::Zlib::Deflate->new(
-WindowBits => Compress::Raw::Zlib::WANT_GZIP(),
-AppendOutput => 1,
);
my $content = "";
$compressor->deflate( $TEST_CONTENT, $content );
$compressor->flush( $content );
( run in 0.629 second using v1.01-cache-2.11-cpan-71847e10f99 )