in reply to How to reconstruct HTTP::Response from file properly

After 12+ hours on this bug hunt, I decided to declare the HTTP::Response->parse() method as buggy parsing gzipped content and switched over to use the HTTP::Parser module:
use HTTP::Parser; my $parser = HTTP::Parser->new(response => 1); my $status = $parser->add( $stored_as_file ); my $restored_response = $parser->object();
The fault does not seem to be on my part, because this module gets the split between header-data and (possibly gzipped)-content-data right every time! If I were on cpan, I would file a bug report for the otherwise rock-solid libwww-perl modules.

A few things to note:
- HTML::Parser does a slight modification reconstructing the original response, adding a X-HTTP-Version header and removing HTTP-Version from the GET line.
- I still don't know if it will munge HTTP/0.9 and HTTP/1.0 right..

update:
And then I found out HTML::Parser breaks on some pages, failing to recognize which part of the message is the content - leading to an empty $content string...

update2:
I decided that I need finer control over the process and now I am using HTTP::MessageParser to re-construct the original response object from file:
my ( $HTTP_Version, $Status_Code, $Reason_Phrase ) = HTTP::MessagePars +er->parse_response_line( $stored_as_file ); my ( $Method, $Request_URI, $HTTP_Version, $Headers, $Body ) = HTTP::M +essageParser->parse_response( $stored_as_file ); my $restored_response= HTTP::Response->new( $Status_Code, $Reason_Phra +se, $Headers, ${$Body} );
and so far it works... (any comments?)