summaryrefslogtreecommitdiffstats
path: root/t/encoding.t
diff options
context:
space:
mode:
Diffstat (limited to 't/encoding.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;