diff --git a/lib/WWW/Mechanize.pm b/lib/WWW/Mechanize.pm index dd5064aa..75e0a4d4 100644 --- a/lib/WWW/Mechanize.pm +++ b/lib/WWW/Mechanize.pm @@ -899,7 +899,8 @@ sub content { my $content = $self->{content}; if ( delete $params{raw} ) { - $content = $self->response()->content(); + my $res = $self->response(); + $content = $res->content() if $res; } elsif ( delete $params{decoded_by_headers} ) { $content = $self->response()->decoded_content( charset => 'none' ); diff --git a/t/content.t b/t/content.t index c146b715..86030dbd 100644 --- a/t/content.t +++ b/t/content.t @@ -37,6 +37,10 @@ my $mech = WWW::Mechanize->new(); $mech->{base} = 'http://example.com/'; is( $mech->content, undef, 'content starts out as undef' ); +is( + $mech->content( raw => 1 ), + undef, 'raw content is just as undef as normal' +); $mech->update_html($html);