From 1aedc237afa0840ad9408d646359d197031d4dff Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Mon, 24 Sep 2012 10:14:50 -0500 Subject: don't pass along an undef encoding object --- t/encoding.t | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 't') diff --git a/t/encoding.t b/t/encoding.t index 9c1d39d..95feb6a 100644 --- a/t/encoding.t +++ b/t/encoding.t @@ -119,4 +119,66 @@ use Web::Request; }; } +{ + my $app = sub { + my ($env) = @_; + my $req = Web::Request->new_from_env($env); + return $req->new_response( + status => 200, + content => "café", + )->finalize; + }; + + test_psgi + app => $app, + client => sub { + my ($cb) = @_; + my $res = $cb->(GET '/'); + ok($res->is_success) || diag($res->content); + is($res->content, "caf\xe9", "content encoded with latin1"); + }; +} + +{ + my $app = sub { + my ($env) = @_; + my $req = Web::Request->new_from_env($env); + $req->encoding('UTF-8'); + return $req->new_response( + status => 200, + content => "café", + )->finalize; + }; + + test_psgi + app => $app, + client => sub { + my ($cb) = @_; + my $res = $cb->(GET '/'); + ok($res->is_success) || diag($res->content); + is($res->content, "caf\xc3\xa9", "content encoded with UTF-8"); + }; +} + +{ + my $app = sub { + my ($env) = @_; + my $req = Web::Request->new_from_env($env); + $req->encoding(undef); + return $req->new_response( + status => 200, + content => "\x01\x02\xf3", + )->finalize; + }; + + test_psgi + app => $app, + client => sub { + my ($cb) = @_; + my $res = $cb->(GET '/'); + ok($res->is_success) || diag($res->content); + is($res->content, "\x01\x02\xf3", "unencoded content"); + }; +} + done_testing; -- cgit v1.2.3-54-g00ecf