1use strict; 2use warnings; 3use Plack::App::Proxy; 4use Plack::Middleware::Proxy::AddVia; 5use Test::More; 6use Plack::App::Proxy::Test; 7 8test_proxy( 9 proxy => sub { 10 Plack::Middleware::Proxy::AddVia->wrap( 11 Plack::App::Proxy->new(remote => "http://$_[0]:$_[1]/"), 12 ), 13 }, 14 app => sub { 15 my $env = shift; 16 like $env->{HTTP_VIA}, qr/^1\.0 ricky, 1\.1 ethel\s*,\s*1\.[01] /; 17 18 [ 200, [ Via => '1.0 lucy' ], [ 'Hello' ] ]; 19 }, 20 client => sub { 21 my $cb = shift; 22 my $req = HTTP::Request->new( GET => "http://localhost/" ); 23 $req->headers->header( Via => '1.0 ricky, 1.1 ethel'); 24 my $res = $cb->($req); 25 like $res->header( 'Via' ), qr/1\.0 lucy\s*,\s*\b1\.[01] /; 26 like $res->header( 'Via' ), qr(${\ quotemeta $req->uri->host}); 27 like $res->header( 'Via' ), qr(${\ quotemeta $req->uri->port}); 28 }, 29); 30 31done_testing; 32