File tree Expand file tree Collapse file tree 6 files changed +27
-5
lines changed Expand file tree Collapse file tree 6 files changed +27
-5
lines changed Original file line number Diff line number Diff line change 1010/MYMETA. *
1111/HTTP-Message- * /
1212/HTTP-Message- * .tar.gz
13+ ** ~
Original file line number Diff line number Diff line change 88 - " 5.14"
99 - " 5.12"
1010 - " 5.10"
11+ - " 5.8"
1112before_install :
1213 - git clone git://github.com/travis-perl/helpers ~/travis-perl-helpers
1314 - source ~/travis-perl-helpers/init
Original file line number Diff line number Diff line change 44^HTTP-Message-.*.tar.gz
55^\.ackrc$
66^test-
7+ ^\.git.*
8+ ^\.travis.yml
Original file line number Diff line number Diff line change @@ -143,11 +143,11 @@ sub _set_content {
143143 my $self = $_ [0];
144144 _utf8_downgrade($_ [1]);
145145 if (!ref ($_ [1]) && ref ($self -> {_content }) eq " SCALAR" ) {
146- ${$self -> {_content }} = $_ [1];
146+ ${$self -> {_content }} = defined ( $_ [1] ) ? $_ [1] : ' ' ;
147147 }
148148 else {
149149 die " Can't set content to be a scalar reference" if ref ($_ [1]) eq " SCALAR" ;
150- $self -> {_content } = $_ [1];
150+ $self -> {_content } = defined ( $_ [1] ) ? $_ [1] : ' ' ;
151151 delete $self -> {_content_ref };
152152 }
153153 delete $self -> {_parts } unless $_ [2];
@@ -835,6 +835,9 @@ The content() method sets the raw content if an argument is given. If no
835835argument is given the content is not touched. In either case the
836836original raw content is returned.
837837
838+ If the C<undef > argument is given, the content is reset to its default value,
839+ which is an empty string.
840+
838841Note that the content should be a string of bytes. Strings in perl
839842can contain characters outside the range of a byte. The C<Encode >
840843module can be used to turn such strings into a string of bytes.
Original file line number Diff line number Diff line change @@ -5,7 +5,9 @@ use Test::More;
55BEGIN {
66 plan skip_all => ' these tests are for authors only!'
77 unless -d ' .git' || $ENV {AUTHOR_TESTING };
8+
9+ plan skip_all => ' these tests require Test::DistManifest'
10+ unless eval { require Test::DistManifest; };
811}
912
10- use Test::DistManifest;
11- manifest_ok();
13+ Test::DistManifest::manifest_ok();
Original file line number Diff line number Diff line change 1+ # ! perl -w
2+
13use strict;
24use warnings;
35
46use Test::More;
57
6- plan tests => 129 ;
8+ plan tests => 131 ;
79
810require HTTP::Message;
911use Config qw( %Config) ;
@@ -22,6 +24,17 @@ is($m->content, "");
2224$m -> header(" Foo" , 1);
2325is($m -> as_string, " Foo: 1\n\n " );
2426
27+ {
28+ # A message with an undef set content
29+ # will stay consistent and have empty string
30+ # as a content
31+ my $m = HTTP::Message-> new();
32+ $m -> content(undef );
33+ is($m -> as_string, " \n " );
34+ is($m -> content, " " );
35+ }
36+
37+
2538$m2 = HTTP::Message-> new($m -> headers);
2639$m2 -> header(bar => 2);
2740is($m -> as_string, " Foo: 1\n\n " );
You can’t perform that action at this time.
0 commit comments