tests and donot let you change encoding too late into the response
[catagits/Catalyst-Runtime.git] / t / utf_incoming.t
index 373a428..638cef5 100644 (file)
@@ -167,10 +167,19 @@ use JSON::MaybeXS;
   sub override_encoding :Local {
     my ($self, $c) = @_;
     $c->res->content_type('text/plain');
+    $c->encoding(Encode::find_encoding('UTF-8'));
     $c->encoding(Encode::find_encoding('Shift_JIS'));
     $c->response->body("テスト");
   }
 
+  sub stream_write_error :Local {
+    my ($self, $c) = @_;
+    $c->response->content_type('text/html');
+    $c->response->write("<p>This is stream_write action ♥</p>");
+    $c->encoding(Encode::find_encoding('Shift_JIS'));
+    $c->response->write("<p>This is stream_write action ♥</p>");
+  }
+
   package MyApp;
   use Catalyst;
 
@@ -395,6 +404,14 @@ SKIP: {
   is $res->content_charset, 'UTF-8';
 }
 
+{
+  my $res = request "/root/stream_write_error";
+
+  is $res->code, 200, 'OK';
+  like decode_utf8($res->content), qr[<p>This is stream_write action ♥</p><!DOCTYPE html], 'correct body';
+}
+
+
 ## should we use binmode on filehandles to force the encoding...?
 ## Not sure what else to do with multipart here, if docs are enough...