1 2 3 4 5 6 7 8 9 10
use LWP::UserAgent; my $ua = LWP::UserAgent->new; my $response = $ua->get('http://search.cpan.org/'); while ($response) { say $response->$response->as_string(); # oder mach sonstwas damit $response = $response->previous(); }
QuoteHTTP::Body parses chunks of HTTP POST data and supports application/octet-stream, application/json, application/x-www-form-urlencoded, and multipart/form-data.
2015-10-22T12:28:23 GwenDragonUm das klar zu bekommen: Du benutzt eine TCP-Verbindung über HTTP, lässt die offen, und schickst darüber nacheinander mehrere Requests und willst diese weider einlesen.
Das läuft doch synchron ab. Auf den Request erfolgt die Response usw.
1 2 3 4 5 6 7 8 9 10 11
my $ro = HTTPRequest->new( host => 'www-proxy.t-online.de', http => '1.1' ) or die $!; $ro->request( method => 'PUT', uri => 'http://example.com', content => 'asdf', Connection => 'Keep-Alive'); $ro->request( method => 'GET', uri => 'http://example.com', Connection => 'Close'); my $messages = $ro->response_slice; # Array [{statuscode => '', body => '', usw.}] # alle Response-Headers sind drin in jeder {}