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 10
10
/MYMETA. *
11
11
/HTTP-Message- * /
12
12
/HTTP-Message- * .tar.gz
13
+ ** ~
Original file line number Diff line number Diff line change 8
8
- " 5.14"
9
9
- " 5.12"
10
10
- " 5.10"
11
+ - " 5.8"
11
12
before_install :
12
13
- git clone git://github.com/travis-perl/helpers ~/travis-perl-helpers
13
14
- source ~/travis-perl-helpers/init
Original file line number Diff line number Diff line change 4
4
^HTTP-Message-.*.tar.gz
5
5
^\.ackrc$
6
6
^test-
7
+ ^\.git.*
8
+ ^\.travis.yml
Original file line number Diff line number Diff line change @@ -143,11 +143,11 @@ sub _set_content {
143
143
my $self = $_ [0];
144
144
_utf8_downgrade($_ [1]);
145
145
if (!ref ($_ [1]) && ref ($self -> {_content }) eq " SCALAR" ) {
146
- ${$self -> {_content }} = $_ [1];
146
+ ${$self -> {_content }} = defined ( $_ [1] ) ? $_ [1] : ' ' ;
147
147
}
148
148
else {
149
149
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] : ' ' ;
151
151
delete $self -> {_content_ref };
152
152
}
153
153
delete $self -> {_parts } unless $_ [2];
@@ -835,6 +835,9 @@ The content() method sets the raw content if an argument is given. If no
835
835
argument is given the content is not touched. In either case the
836
836
original raw content is returned.
837
837
838
+ If the C<undef > argument is given, the content is reset to its default value,
839
+ which is an empty string.
840
+
838
841
Note that the content should be a string of bytes. Strings in perl
839
842
can contain characters outside the range of a byte. The C<Encode >
840
843
module 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;
5
5
BEGIN {
6
6
plan skip_all => ' these tests are for authors only!'
7
7
unless -d ' .git' || $ENV {AUTHOR_TESTING };
8
+
9
+ plan skip_all => ' these tests require Test::DistManifest'
10
+ unless eval { require Test::DistManifest; };
8
11
}
9
12
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
+
1
3
use strict;
2
4
use warnings;
3
5
4
6
use Test::More;
5
7
6
- plan tests => 129 ;
8
+ plan tests => 131 ;
7
9
8
10
require HTTP::Message;
9
11
use Config qw( %Config) ;
@@ -22,6 +24,17 @@ is($m->content, "");
22
24
$m -> header(" Foo" , 1);
23
25
is($m -> as_string, " Foo: 1\n\n " );
24
26
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
+
25
38
$m2 = HTTP::Message-> new($m -> headers);
26
39
$m2 -> header(bar => 2);
27
40
is($m -> as_string, " Foo: 1\n\n " );
You can’t perform that action at this time.
0 commit comments