summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2012-09-24 10:14:50 -0500
committerJesse Luehrs <doy@tozt.net>2012-09-24 10:23:51 -0500
commit1aedc237afa0840ad9408d646359d197031d4dff (patch)
tree136bf14543db4ab86a7b11db43aae9c91af8775a /t
parent4310a8e3c45dcad070981eb572ccfcb877f8233f (diff)
downloadweb-request-1aedc237afa0840ad9408d646359d197031d4dff.tar.gz
web-request-1aedc237afa0840ad9408d646359d197031d4dff.zip
don't pass along an undef encoding object
Diffstat (limited to 't')
-rw-r--r--t/encoding.t62
1 files changed, 62 insertions, 0 deletions
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;