]>
Dogcows Code - chaz/p5-HTTP-AnyUA/blob - lib/HTTP/AnyUA/Backend/LWP/UserAgent.pm
1 package HTTP
::AnyUA
::Backend
::LWP
::UserAgent
;
2 # ABSTRACT: A unified programming interface for LWP::UserAgent
6 This module adds support for the HTTP client L<LWP::UserAgent> to be used with the unified
7 programming interface provided by L<HTTP::AnyUA>.
12 * L<HTTP::AnyUA::Backend>
19 our $VERSION = '9999.999'; # VERSION
21 use parent
'HTTP::AnyUA::Backend';
23 use HTTP
::AnyUA
::Util
;
28 my ($method, $url, $args) = @_;
30 my $r = HTTP
::AnyUA
::Util
::native_to_http_request
(@_);
32 my $ua_resp = $self->ua->request($r);
34 return $self->_munge_response($ua_resp, $args->{data_callback
});
45 success
=> !!$ua_resp->is_success,
46 url
=> $ua_resp->request->uri->as_string,
47 status
=> $ua_resp->code,
48 reason
=> $ua_resp->message,
49 headers
=> HTTP
::AnyUA
::Util
::http_headers_to_native
($ua_resp->headers),
52 $resp->{protocol
} = $ua_resp->protocol if $ua_resp->protocol;
55 for my $redirect ($ua_resp->redirects) {
56 push @{$resp->{redirects
} ||= []}, $self->_munge_response($redirect, undef, 1);
60 my $content_ref = $ua_resp->content_ref;
62 if (($resp->{headers
}{'client-warning'} || '') eq 'Internal response') {
63 HTTP
::AnyUA
::Util
::internal_exception
($$content_ref, $resp);
66 $data_cb->($$content_ref, $resp);
69 $resp->{content
} = $$content_ref;
This page took 0.035016 seconds and 4 git commands to generate.