Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Michael Houghton (1):
Modified HTTP::Message::new to check $content to see if it is a ref.
Use the content_ref method to add $content in properly if it is a ref.
This addresses issue #13 in GitHub
Test added to t/message.t that fails in 6.06

_______________________________________________________________________________
2015-04-23 HTTP-Message 6.07

Added support for is_client_error, is_server_error to HTTP::Response
(Karen Etheridge)
Expand Down
8 changes: 7 additions & 1 deletion lib/HTTP/Message.pm
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,16 @@ sub new
$content = '';
}

bless {
my $self = bless {
'_headers' => $header,
'_content' => $content,
}, $class;

# docs say content should be bytes, but refs are OK
# the code above does not downgrade a ref properly, so this will do the trick
$self->content_ref($content) if (ref($content));

return $self;
}


Expand Down
8 changes: 7 additions & 1 deletion t/message.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use strict;
use Test qw(plan ok skip);

plan tests => 129;
plan tests => 131;

require HTTP::Message;
use Config qw(%Config);
Expand Down Expand Up @@ -492,3 +492,9 @@ else {
# test decoding of XML content
$m = HTTP::Message->new(["Content-Type", "application/xml"], "\xFF\xFE<\0?\0x\0m\0l\0 \0v\0e\0r\0s\0i\0o\0n\0=\0\"\x001\0.\x000\0\"\0 \0e\0n\0c\0o\0d\0i\0n\0g\0=\0\"\0U\0T\0F\0-\x001\x006\0l\0e\0\"\0?\0>\0\n\0<\0r\0o\0o\0t\0>\0\xC9\0r\0i\0c\0<\0/\0r\0o\0o\0t\0>\0\n\0");
ok($m->decoded_content, "<?xml version=\"1.0\"?>\n<root>\xC9ric</root>\n");

#
$foo = "фу"; # Cyrillic "foo"
$m = HTTP::Message->new(undef, \$foo);
ok($m->content, "фу");
ok($m->decoded_content, "фу");