Guest User

Untitled

a guest
Jun 20th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. sub get {
  2. my($self, $uri, $cb_gen) = @_;
  3.  
  4. my $http = HTTP::Lite->new;
  5. $http->http11_mode(1); # hopefully, CPAN mirrors can handle this
  6.  
  7. my $retries = 0;
  8. while ( $retries++ < 5 ) {
  9. my $rc = $self->_make_request( $http, $uri, $data_cb );
  10. if ( $rc == 401 ) {
  11. last unless $self->_prepare_auth( $http, 'non_proxy' );
  12. }
  13. elsif ( $rc == 407 ) {
  14. last unless $self->_prepare_auth( $http, 'proxy' );
  15. }
  16. elsif ( $rc == 301 || $rc == 302 ) {
  17. $uri = $self->_get_redirect( $http, $uri );
  18. }
  19. else {
  20. last;
  21. }
  22. }
  23.  
  24. return $http;
  25. }
Add Comment
Please, Sign In to add comment