[Catalyst-commits] r11978 - in Catalyst-Runtime/5.80/trunk: . lib
t/aggregate t/lib t/lib/TestApp/Controller
t/lib/TestAppEncoding t/lib/TestAppEncoding/Controller
t0m at dev.catalyst.perl.org
t0m at dev.catalyst.perl.org
Mon Nov 23 21:25:20 GMT 2009
Author: t0m
Date: 2009-11-23 21:25:19 +0000 (Mon, 23 Nov 2009)
New Revision: 11978
Added:
Catalyst-Runtime/5.80/trunk/t/aggregate/utf8_content_length.t
Catalyst-Runtime/5.80/trunk/t/lib/TestAppEncoding.pm
Catalyst-Runtime/5.80/trunk/t/lib/TestAppEncoding/
Catalyst-Runtime/5.80/trunk/t/lib/TestAppEncoding/Controller/
Catalyst-Runtime/5.80/trunk/t/lib/TestAppEncoding/Controller/Root.pm
Modified:
Catalyst-Runtime/5.80/trunk/
Catalyst-Runtime/5.80/trunk/Changes
Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm
Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Root.pm
Log:
Don't do bytes::length, just use length, tests to demonstrate the issue
Property changes on: Catalyst-Runtime/5.80/trunk
___________________________________________________________________
Name: svn:ignore
- Catalyst-Runtime-*
META.yml
Makefile.old
.gdb_history
pm_to_blib
nytprof.out
blib
inc
Makefile
.*.swp
+ MANIFEST
MANIFEST.bak
Catalyst-Runtime-*
META.yml
Makefile.old
.gdb_history
pm_to_blib
nytprof.out
blib
inc
Makefile
.*.swp
Modified: Catalyst-Runtime/5.80/trunk/Changes
===================================================================
--- Catalyst-Runtime/5.80/trunk/Changes 2009-11-23 20:08:41 UTC (rev 11977)
+++ Catalyst-Runtime/5.80/trunk/Changes 2009-11-23 21:25:19 UTC (rev 11978)
@@ -1,5 +1,12 @@
# This file documents the revision history for Perl extension Catalyst.
+ Bug fixes:
+ - Fix reporting the wrong Content-Length if the response body is an
+ upgraded string. Strings mean the same thing whether or not they are
+ upgraded, may get upgraded even after they are encoded, and will
+ produce the same output either way, but bytes::length returns too big
+ values for upgraded strings containing characters >127
+
Refactoring / cleanups:
- NoTabs and Pod tests moved to t/author so that they're not run
(and then skipped) normally.
Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm 2009-11-23 20:08:41 UTC (rev 11977)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm 2009-11-23 21:25:19 UTC (rev 11978)
@@ -4,7 +4,6 @@
use Moose::Meta::Class ();
extends 'Catalyst::Component';
use Moose::Util qw/find_meta/;
-use bytes;
use B::Hooks::EndOfScope ();
use Catalyst::Exception;
use Catalyst::Exception::Detach;
@@ -1793,7 +1792,7 @@
}
else {
# everything should be bytes at this point, but just in case
- $response->content_length( bytes::length( $response->body ) );
+ $response->content_length( length( $response->body ) );
}
}
Added: Catalyst-Runtime/5.80/trunk/t/aggregate/utf8_content_length.t
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/aggregate/utf8_content_length.t (rev 0)
+++ Catalyst-Runtime/5.80/trunk/t/aggregate/utf8_content_length.t 2009-11-23 21:25:19 UTC (rev 11978)
@@ -0,0 +1,30 @@
+use strict;
+use warnings;
+use FindBin qw/$Bin/;
+use lib "$Bin/../lib";
+use File::Spec;
+use Test::More;
+
+use Catalyst::Test qw/TestAppEncoding/;
+
+if ( $ENV{CATALYST_SERVER} ) {
+ plan skip_all => 'This test does not run live';
+ exit 0;
+}
+
+my $fn = "$Bin/../catalyst_130pix.gif";
+ok -r $fn, 'Can read catalyst_130pix.gif';
+my $size = -s $fn;
+{
+ my $r = request('/binary');
+ is $r->code, 200, '/binary OK';
+ is $r->header('Content-Length'), $size, '/binary correct content length';
+}
+{
+ my $r = request('/binary_utf8');
+ is $r->code, 200, '/binary_utf8 OK';
+ is $r->header('Content-Length'), $size, '/binary_utf8 correct content length';
+}
+
+done_testing;
+
Modified: Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Root.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Root.pm 2009-11-23 20:08:41 UTC (rev 11977)
+++ Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Root.pm 2009-11-23 21:25:19 UTC (rev 11978)
@@ -1,5 +1,6 @@
package TestApp::Controller::Root;
-
+use strict;
+use warnings;
use base 'Catalyst::Controller';
__PACKAGE__->config->{namespace} = '';
Added: Catalyst-Runtime/5.80/trunk/t/lib/TestAppEncoding/Controller/Root.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/lib/TestAppEncoding/Controller/Root.pm (rev 0)
+++ Catalyst-Runtime/5.80/trunk/t/lib/TestAppEncoding/Controller/Root.pm 2009-11-23 21:25:19 UTC (rev 11978)
@@ -0,0 +1,27 @@
+package TestAppEncoding::Controller::Root;
+use strict;
+use warnings;
+use base 'Catalyst::Controller';
+use Test::More;
+
+__PACKAGE__->config->{namespace} = '';
+
+sub binary : Local {
+ my ($self, $c) = @_;
+ $c->res->body(do { open(my $fh, '<', $c->path_to('..', '..', 'catalyst_130pix.gif')) or die $!; local $/ = undef; <$fh>; });
+}
+
+sub binary_utf8 : Local {
+ my ($self, $c) = @_;
+ $c->forward('binary');
+ my $str = $c->res->body;
+ utf8::upgrade($str);
+ ok utf8::is_utf8($str), 'Body is variable width encoded string';
+ $c->res->body($str);
+}
+
+sub end : Private {
+ my ($self,$c) = @_;
+}
+
+1;
Added: Catalyst-Runtime/5.80/trunk/t/lib/TestAppEncoding.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/lib/TestAppEncoding.pm (rev 0)
+++ Catalyst-Runtime/5.80/trunk/t/lib/TestAppEncoding.pm 2009-11-23 21:25:19 UTC (rev 11978)
@@ -0,0 +1,11 @@
+package TestAppEncoding;
+use strict;
+use warnings;
+use base qw/Catalyst/;
+use Catalyst;
+
+__PACKAGE__->config(name => __PACKAGE__);
+__PACKAGE__->setup;
+
+1;
+
More information about the Catalyst-commits
mailing list