Skip to content

Commit

Permalink
Undo special-casing location() setter. plack#224
Browse files Browse the repository at this point in the history
  • Loading branch information
miyagawa committed Jun 10, 2011
1 parent c0c8067 commit 877e10d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
10 changes: 1 addition & 9 deletions lib/Plack/Response.pm
Expand Up @@ -9,7 +9,6 @@ use Carp ();
use Scalar::Util ();
use HTTP::Headers;
use URI::Escape ();
use URI ();

sub code { shift->status(@_) }
sub content { shift->body(@_) }
Expand Down Expand Up @@ -67,14 +66,7 @@ sub content_encoding {

sub location {
my $self = shift;

if (@_) {
my $uri = shift;
my $loc = URI->new($uri)->as_string;
$self->headers->header('Location' => $loc);
}

return $self->headers->header('Location');
return $self->headers->header('Location' => @_);
}

sub redirect {
Expand Down
4 changes: 2 additions & 2 deletions t/Plack-Response/redirect.t
Expand Up @@ -21,11 +21,11 @@ use URI;

{
my $uri_invalid = "http://www.google.com/\r\nX-Injection: true\r\n\r\nHello World";
my $uri_valid = URI->new($uri_invalid)->as_string;

my $res = Plack::Response->new;
$res->redirect($uri_invalid, 301);
is_deeply $res->finalize, [ 301, [ 'Location' => $uri_valid ], [] ];
my $psgi_res = $res->finalize;
ok $psgi_res->[1][1] !~ /\n/;
}

done_testing;

0 comments on commit 877e10d

Please sign in to comment.