From cd517595023d87ea9d783b3c8f0efa8998c56dac Mon Sep 17 00:00:00 2001 From: "Miller, Andrew | Andrew | OSPD" Date: Mon, 24 Mar 2014 15:43:56 +0900 Subject: [PATCH] Content length should be based on the byte size of the content rather than the string length. --- lib/Sledge/Pages/Base.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/Sledge/Pages/Base.pm b/lib/Sledge/Pages/Base.pm index 5db7f68..62a5d0f 100644 --- a/lib/Sledge/Pages/Base.pm +++ b/lib/Sledge/Pages/Base.pm @@ -55,6 +55,11 @@ use Class::Trigger qw(BEFORE_INIT AFTER_INIT BEFORE_DISPATCH AFTER_DISPATCH AFTE *register_hook = \&add_trigger; *invoke_hook = \&call_trigger; +sub bytes($) { + require bytes; + return length shift; +} + sub new { my $class = shift; my $self = bless {}, $class; @@ -123,7 +128,7 @@ sub output_content { my $self = shift; $self->r->content_type($self->charset->content_type); # set my $content = $self->make_content; - $self->set_content_length(length $content); + $self->set_content_length(bytes $content); $self->send_http_header; $self->r->print($content); $self->invoke_hook('AFTER_OUTPUT');