Skip to content

Commit

Permalink
In Catalyst::Test, don't mangle headers of non-HTML responses. RT#79043
Browse files Browse the repository at this point in the history
  • Loading branch information
ilmari committed Aug 17, 2012
1 parent f0580bf commit d0cacee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@
issue with new versions of Module::Runtime (0.012) on perl 5.10
which stopped Catalyst::Controller from compiling.

- In Catalyst::Test, don't mangle headers of non-HTML responses. RT#79043

5.90008 - TRIAL 2012-02-06 20:49:00

New features and refactoring:
Expand Down
18 changes: 10 additions & 8 deletions lib/Catalyst/Test.pm
Original file line number Diff line number Diff line change
Expand Up @@ -305,16 +305,18 @@ sub _local_request {
# getting it into Plack::Test, or make a middleware out of it, or
# whatever. Seriously - horrible.

require HTML::HeadParser;
if (!$resp->content_type || $resp->content_is_html) {
require HTML::HeadParser;

my $parser = HTML::HeadParser->new();
$parser->xml_mode(1) if $resp->content_is_xhtml;
$parser->utf8_mode(1) if $] >= 5.008 && $HTML::Parser::VERSION >= 3.40;
my $parser = HTML::HeadParser->new();
$parser->xml_mode(1) if $resp->content_is_xhtml;
$parser->utf8_mode(1) if $] >= 5.008 && $HTML::Parser::VERSION >= 3.40;

$parser->parse( $resp->content );
my $h = $parser->header;
for my $f ( $h->header_field_names ) {
$resp->init_header( $f, [ $h->header($f) ] );
$parser->parse( $resp->content );
my $h = $parser->header;
for my $f ( $h->header_field_names ) {
$resp->init_header( $f, [ $h->header($f) ] );
}
}
# Another horrible hack to make the response headers have a
# 'status' field. This is for back-compat, but you should
Expand Down

0 comments on commit d0cacee

Please sign in to comment.