Skip to content

Commit 1b4267a

Browse files
mikkoioalders
authored andcommitted
Fix content(raw=>1) dies when there is no response
* #384
1 parent 4a3a30d commit 1b4267a

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

lib/WWW/Mechanize.pm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,8 @@ sub content {
868868

869869
my $content = $self->{content};
870870
if ( delete $params{raw} ) {
871-
$content = $self->response()->content();
871+
my $res = $self->response();
872+
$content = $res->content() if $res;
872873
}
873874
elsif ( delete $params{decoded_by_headers} ) {
874875
$content = $self->response()->decoded_content( charset => 'none' );

t/content.t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ my $mech = WWW::Mechanize->new();
3737
$mech->{base} = 'http://example.com/';
3838

3939
is( $mech->content, undef, 'content starts out as undef' );
40+
is( $mech->content(raw=>1), undef, 'raw content is just as undef as normal' );
4041

4142
$mech->update_html($html);
4243

0 commit comments

Comments
 (0)