Created
November 5, 2010 02:28
-
-
Save dagolden/663557 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
sub get { | |
my($self, $uri, $cb_gen) = @_; | |
my $http = HTTP::Lite->new; | |
$http->http11_mode(1); # hopefully, CPAN mirrors can handle this | |
my $retries = 0; | |
while ( $retries++ < 5 ) { | |
my $rc = $self->_make_request( $http, $uri, $data_cb ); | |
if ( $rc == 401 ) { | |
last unless $self->_prepare_auth( $http, 'non_proxy' ); | |
} | |
elsif ( $rc == 407 ) { | |
last unless $self->_prepare_auth( $http, 'proxy' ); | |
} | |
elsif ( $rc == 301 || $rc == 302 ) { | |
$uri = $self->_get_redirect( $http, $uri ); | |
} | |
else { | |
last; | |
} | |
} | |
return $http; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment