Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
handle all 303 redirects with a GET method
  • Loading branch information
jberger committed Sep 18, 2016
1 parent 2668dc9 commit c88d919
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/Mojo/UserAgent/Transactor.pm
Expand Up @@ -90,7 +90,9 @@ sub redirect {
}
else {
my $method = uc $req->method;
my $headers = $new->req->method($method eq 'POST' ? 'GET' : $method)
my $headers
= $new->req->method(
$code == 303 ? 'GET' : $method eq 'POST' ? 'GET' : $method)
->content->headers($req->headers->clone)->headers;
$headers->remove($_) for grep {/^content-/i} @{$headers->names};
}
Expand Down
2 changes: 1 addition & 1 deletion t/mojo/transactor.t
Expand Up @@ -720,7 +720,7 @@ is $tx->res->code, undef, 'no status';
is $tx->res->headers->location, undef, 'no "Location" value';

# 303 redirect (dynamic)
$tx = $t->tx(POST => 'http://mojolicious.org/foo');
$tx = $t->tx(PUT => 'http://mojolicious.org/foo');
$tx->res->code(303);
$tx->res->headers->location('http://example.com/bar');
$tx->req->content->write_chunk('whatever' => sub { shift->finish });
Expand Down

0 comments on commit c88d919

Please sign in to comment.