Created
November 4, 2010 13:33
-
-
Save wchristian/662462 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
package test_case; | |
use HTTP::Request::Common qw'POST GET'; | |
use LWP::UserAgent; | |
use AnyEvent::HTTP; | |
use Data::Dumper; | |
my $url = "https://traffics20.flightconex.de/tourconex/servlet/XmlServlet"; | |
my $post_req = POST $url, [ request => "test" ]; | |
my $get_req = GET "$url?request=test"; | |
print Dumper($post_req->as_string)."\n"; | |
print Dumper($get_req->as_string)."\n"; | |
my %responses; | |
my $ua = LWP::UserAgent->new; | |
$responses{lwp}{POST} = $ua->request( $post_req )->content; | |
$responses{lwp}{GET} = $ua->request( $get_req )->content; | |
my $cv = AnyEvent->condvar; | |
register_request($post_req); | |
register_request($get_req); | |
$cv->recv; | |
for my $engine ( qw( lwp ae ) ) { | |
for my $method ( qw( POST GET ) ) { | |
$responses{$engine}{$method} = substr $responses{$engine}{$method}, 0, 55; | |
} | |
} | |
print Dumper( \%responses ); | |
exit; | |
sub register_request { | |
my ( $req ) = @_; | |
$cv->begin; | |
my $method = $req->method; | |
http_request( | |
$method, | |
$req->uri->as_string, | |
body => $req->content, | |
headers => $req->{_headers}, | |
sub { | |
$responses{ae}{$method} = $_[0]; | |
$cv->end; | |
} | |
); | |
return; | |
} | |
__END__ | |
$VAR1 = 'POST https://traffics20.flightconex.de/tourconex/servlet/XmlServlet | |
Content-Length: 12 | |
Content-Type: application/x-www-form-urlencoded | |
request=test | |
'; | |
$VAR1 = 'GET https://traffics20.flightconex.de/tourconex/servlet/XmlServlet?request=test | |
'; | |
$VAR1 = { | |
'ae' => { | |
'POST' => '<html><head><title>JBossWeb/2.0.1.GA - Error report</ti', | |
'GET' => '<html><head><title>JBossWeb/2.0.1.GA - Error report</ti' | |
}, | |
'lwp' => { | |
'POST' => '<html><head><title>JBossWeb/2.0.1.GA - Error report</ti', | |
'GET' => '<html><head><title>JBossWeb/2.0.1.GA - Error report</ti' | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment