Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Expanded the version 0.03.

  • Loading branch information...
commit 390629f044b38696c937488b47cb8fbc327c08cc 1 parent 66bae6c
@hiratara hiratara authored
View
8 Changes
@@ -1,5 +1,11 @@
Revision history for Plack-App-Proxy
-0.01 Date/time
+0.03 12/30/2009
+ Don't use google.com for tests because of localizations
+
+0.02 12/25/2009
+ Forgot to include Makefile.PL
+
+0.01 12/22/2009
First version, released on an unsuspecting world.
View
2  Makefile.PL
@@ -2,7 +2,7 @@ use inc::Module::Install;
name 'Plack-App-Proxy';
all_from 'lib/Plack/App/Proxy.pm';
readme_from 'lib/Plack/App/Proxy.pm';
-build_requires 'Test::More';
+test_requires 'Test::More';
requires 'Plack';
requires 'Plack::Request';
requires 'AnyEvent::HTTP' => 1.44;
View
5 lib/Plack/App/Proxy.pm
@@ -6,7 +6,7 @@ use Plack::Util::Accessor qw/host url preserve_host_header/;
use Plack::Request;
use Try::Tiny;
-our $VERSION = '0.01';
+our $VERSION = '0.03';
sub call {
my ($self, $env) = @_;
@@ -30,7 +30,6 @@ sub call {
else {
die "Neither proxy host nor URL are specified";
}
-
my @headers = ("X-Forwarded-For", $env->{REMOTE_ADDR});
if ($self->preserve_host_header and $env->{HTTP_HOST}) {
push @headers, "Host", $env->{HTTP_HOST};
@@ -167,4 +166,4 @@ it under the same terms as Perl itself.
L<Plack::Builder>
-=cut
+=cut
View
18 t/01-request.t
@@ -1,15 +1,15 @@
use Plack::App::Proxy;
use Plack::Test;
use Test::More tests => 5;
-
+
# regular static proxy
test_psgi
- app => Plack::App::Proxy->new(host => "http://www.google.com"),
+ app => Plack::App::Proxy->new(host => "http://www.cpan.org/"),
client => sub {
my $cb = shift;
my $req = HTTP::Request->new(GET => "http://localhost/index.html");
my $res = $cb->($req);
- like $res->content, qr/Google Search/, "static proxy";
+ like $res->content, qr/CPAN/, "static proxy";
};
# Get the proxy host from the Host header
@@ -21,9 +21,9 @@ test_psgi
client => sub {
my $cb = shift;
my $req = HTTP::Request->new(
- GET => "http://localhost/index.html", [Host => "www.google.com"]);
+ GET => "http://localhost/index.html", [Host => "www.cpan.org"]);
my $res = $cb->($req);
- is $res->request->header("host"), "www.google.com", "dynamic host";
+ is $res->request->header("host"), "www.cpan.org", "dynamic host";
};
# Host callback returns forbidden response instead of host
@@ -39,7 +39,7 @@ test_psgi
# Don't rewrite the Host header
test_psgi
app => Plack::App::Proxy->new(
- host => "http://www.google.com/",
+ host => "http://www.cpan.org/",
preserve_host_header => 1,
),
client => sub {
@@ -59,7 +59,7 @@ test_psgi
}),
client => sub {
my $cb = shift;
- my $req = HTTP::Request->new(GET => "http://localhost/http://www.google.com");
+ my $req = HTTP::Request->new(GET => "http://localhost/http://www.cpan.org/");
my $res = $cb->($req);
- like $res->content, qr/Google Search/, "url callback";
- };
+ like $res->content, qr/CPAN/, "url callback";
+ };
Please sign in to comment.
Something went wrong with that request. Please try again.