Hi!
I am having a lot of trouble reconstructing a full http response from a file.
I (simplified) used:
my $response = $useragent->get($url);
my $stored_as_file = $response->as_string;
to store the full http response to a file. Then, I'd like to recreate this response object by doing:
my $response = HTTP::Response->parse( $stored_as_file );
And it does not work! It seems as if the problem arises only on gzipped content. I used the "accept: gzip" header in the original GET and everything arrives ok and is stored ok to disk. But when I use the parse method, a first part of the still gzipped content ends up as header field, thus breaking the rest of the gzipped binary data in the content part of the http response. It seems as if the parse method does not properly split the header and the content at the "\n\n", but a bit later down the page, thus interpreting parts of the gzipped data as a header field...
Am I using the "parse" method not right? Is it not meant to parse a whole response?
Or is there another solution, maybe tricking LWP::UserAgent into reading from disk and not from the web? Like
reversing $ua->get( $url, :content_file )?
(This is exactly what I'd like to do!)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.