Permalink
Browse files

Deprecated (undocumented anyway) raw_uri infavor of base and request_…

…uri.
  • Loading branch information...
miyagawa committed Jan 27, 2010
1 parent 8d07f70 commit 9f269c8346fd910eb4d99d4f35049f85f451358f
Showing with 32 additions and 26 deletions.
  1. +10 −6 lib/Plack/Request.pm
  2. +0 −20 t/Plack-Request/raw_uri.t
  3. +22 −0 t/Plack-Request/request_uri.t
View
@@ -186,7 +186,7 @@ sub upload {
return $self->uploads->get_all($key);
}
-sub raw_uri {
+sub base {
my $self = shift;
my $env = $self->env;
@@ -200,16 +200,20 @@ sub raw_uri {
};
my $uri = "$scheme\://$host" . $env->{REQUEST_URI};
- return URI->new($uri);
+ $uri = URI->new($uri);
+ $uri->path_query($self->env->{SCRIPT_NAME} || "/");
+
+ return $uri;
}
-sub base {
+sub raw_uri {
my $self = shift;
+ _deprecated 'base';
- my $uri = $self->raw_uri;
- $uri->path_query($self->env->{SCRIPT_NAME} || "/");
+ my $base = $self->base;
+ $base->path_query($self->env->{REQUEST_URI});
- return $uri;
+ $base;
}
sub uri {
View
@@ -1,20 +0,0 @@
-use strict;
-use HTTP::Message::PSGI;
-use Test::More;
-use Plack::Request;
-use HTTP::Request::Common;
-
-my $raw_uri;
-
-my $app = sub {
- my $req = Plack::Request->new(shift);
- $raw_uri = $req->raw_uri;
-};
-
-$app->(req_to_psgi(GET "http://localhost/foo%20bar"));
-is $raw_uri, 'http://localhost/foo%20bar';
-
-$app->(req_to_psgi(GET "http://localhost:2020/FOO/bar,baz"));
-is $raw_uri, 'http://localhost:2020/FOO/bar,baz';
-
-done_testing;
@@ -0,0 +1,22 @@
+use strict;
+use Test::More;
+use Plack::Request;
+use Plack::Test;
+use HTTP::Request::Common;
+
+my $app = sub {
+ my $req = Plack::Request->new(shift);
+ return [ 200, [], [ $req->request_uri ] ];
+};
+
+test_psgi $app, sub {
+ my $cb = shift;
+
+ my $res = $cb->(GET "http://localhost/foo%20bar");
+ is $res->content, '/foo%20bar';
+
+ $res = $cb->(GET "http://localhost:2020/FOO/bar,baz");
+ is $res->content, '/FOO/bar,baz';
+};
+
+done_testing;

0 comments on commit 9f269c8

Please sign in to comment.