diff --git a/lib/LWP/Protocol.pm b/lib/LWP/Protocol.pm index ea2fdc35c..b553809a8 100644 --- a/lib/LWP/Protocol.pm +++ b/lib/LWP/Protocol.pm @@ -161,9 +161,12 @@ sub collect } } }; - if ($@) { - chomp($@); - $response->push_header('X-Died' => $@); + my $err = $@; + delete $response->{handlers}{response_data}; + delete $response->{handlers} unless %{$response->{handlers}}; + if ($err) { + chomp($err); + $response->push_header('X-Died' => $err); $response->push_header("Client-Aborted", "die"); return $response; }