summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2011-01-06 12:53:46 -0600
committerJesse Luehrs <doy@tozt.net>2011-01-06 12:53:46 -0600
commit5cd0eab98e088720e6090e8533b1fb8e52a8a214 (patch)
tree59e663485af84ace1074847c39130c1049714b4b
parent924dce6d566b8334fd7031688796c46cb7ebe696 (diff)
downloadplack-client-5cd0eab98e088720e6090e8533b1fb8e52a8a214.tar.gz
plack-client-5cd0eab98e088720e6090e8533b1fb8e52a8a214.zip
handle env hashes too
this is getting uglier and uglier - need to rethink this i think
-rw-r--r--lib/Plack/Client.pm11
-rw-r--r--t/02-inputs.t10
2 files changed, 16 insertions, 5 deletions
diff --git a/lib/Plack/Client.pm b/lib/Plack/Client.pm
index d97f44c..5a2abb4 100644
--- a/lib/Plack/Client.pm
+++ b/lib/Plack/Client.pm
@@ -41,8 +41,15 @@ sub request {
my $scheme = $req->uri->scheme;
my $app;
if ($scheme eq 'psgi-local') {
- $req->uri->path('/') unless length $req->uri->path;
- $app = $self->app_for($req->uri->authority);
+ if ($req->isa('Plack::Request')) {
+ $req->env->{REQUEST_URI} = '/' unless length $req->request_uri;
+ }
+ else {
+ $req->uri->path('/') unless length $req->uri->path;
+ }
+ my $app_name = $req->uri->authority;
+ $app_name =~ s/:.*//;
+ $app = $self->app_for($app_name);
$app = Plack::Middleware::ContentLength->wrap($app);
}
elsif ($scheme eq 'http' || $scheme eq 'https') {
diff --git a/t/02-inputs.t b/t/02-inputs.t
index 1489175..4b27630 100644
--- a/t/02-inputs.t
+++ b/t/02-inputs.t
@@ -125,14 +125,18 @@ sub test_responses {
"GET\n/\n\n"
);
- { local $TODO = "actually, i have no idea if this even makes sense";
+ my $uri = URI->new($base_uri);
+ $uri->scheme('http')
+ if $base_uri =~ /psgi-local/;
+ my $env = HTTP::Request->new(GET => $uri)->to_psgi;
+ $env->{'psgi.url_scheme'} = 'psgi-local'
+ if $base_uri =~ /psgi-local/;
response_is(
- $client->request(HTTP::Request->new(GET => $base_uri)),
+ $client->request($env),
200,
['Content-Type' => 'text/plain', 'Content-Length' => '7'],
"GET\n/\n\n"
);
- }
}
done_testing;