Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Sep 25, 2010
1 parent 836e49d commit 0c717b7
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/Mojo/Client.pm
Expand Up @@ -873,12 +873,15 @@ sub _redirect {
return unless my $location = $res->headers->location;
$location = Mojo::URL->new($location);

# Fix broken redirects without authority
$location->authority($old->req->url->authority)
# Request
my $req = $old->req;

# Fix broken location without authority
$location->authority($req->url->authority)
unless $location->authority;

# Method
my $method = $old->req->method;
my $method = $req->method;
$method = 'GET' unless $method =~ /^GET|HEAD$/i;

# Max redirects
Expand All @@ -888,9 +891,7 @@ sub _redirect {

# New transaction
my $new = Mojo::Transaction::HTTP->new;
my $req = $new->req;
$req->method($method);
$req->url($location);
$new->req->method($method)->url($location);
$new->previous($old);

# Start redirected request
Expand Down

0 comments on commit 0c717b7

Please sign in to comment.