Subject: | problem using HTTP::Request with POST |
Attached is a script that demonstrates an issue when posting with a HTTP::Request. When using regular AnyEvent::HTTP::http_request it works fine, but when using HTTP::Request and AnyEvent::HTTP::Request it results in a timeout every time.
I'm not sure what the issue is, cause AnyEvent::HTTP has no introspection abilities and I currently don't have access to wireshark to sniff the traffic.
Subject: | a.pl |
#!/usr/bin/perl
use 5.016;
use warnings;
use AnyEvent::HTTP;
use AnyEvent::HTTP::Request;
use AnyEvent::HTTP::Response;
use Data::Printer;
use HTTP::Request::Common;
my $proxy = 'http://45bytes.info/';
my %headers = (
accept => 'text/html,application/xhtml+xml,application/xml;'
. 'q=0.9,*/*;q=0.8',
accept_language => 'en-US,en;q=0.5',
accept_encoding => 'gzip,deflate',
connection => 'keep-alive',
referer => $proxy,
);
my $url = "${proxy}includes/process.php?action=update";
my $cv = AE::cv;
# Works
http_request(
POST => $url,
body => 'u=http%3A%2F%2Fwww.google.com%2F',
headers => {
%headers,
'content-type' => "application/x-www-form-urlencoded",
},
cookie_jar => {},
timeout => 30,
sub { p @_ }
);
my $req = POST $url,
%headers,
content => [
u => 'http://www.google.com/',
];
# Doesn't work. Results in timeout.
AnyEvent::HTTP::Request->new($req => {
params => {
cookie_jar => {},
timeout => 30,
},
cb => sub { p @_ }
})->send;
$cv->recv;