Subject: | [PATCH] content-length is reported in characters but should be bytes |
When the response body value is a utf8 string that contains multi-byte
characters (like umlauts), the content-length is set incorrectly,
because the regular length() function returns characters, not bytes. As
a result, pages appear short or at least missing some close tags.
The attached patch replaces it with the one from the bytes pragma, which
fixed the problem for me.
Subject: | catalyst.patch |
--- Catalyst.pm 2010-09-03 18:59:34.000000000 +0200
+++ site_perl/5.10.1/Catalyst.pm 2010-09-03 18:48:59.000000000 +0200
@@ -29,6 +29,7 @@ use Tree::Simple::Visitor::FindByUID;
use Class::C3::Adopt::NEXT;
use List::MoreUtils qw/uniq/;
use attributes;
+use bytes;
use utf8;
use Carp qw/croak carp shortmess/;
@@ -1833,7 +1834,7 @@ sub finalize_headers {
}
else {
# everything should be bytes at this point, but just in case
- $response->content_length( length( $response->body ) );
+ $response->content_length( bytes::length( $response->body ) );
}
}