Hello again Monks,

I want to thank everyone that responds to my questions. I sincerely appreciate the help.

In the past I have received answers for using HTTP::Proxy, and I have learned how to use it and like it a lot. Very fast. My question, now, is about how to use stored header files to recreate the headers for a stored file (URI). I can successfully send the content of the file back to the client via:

my $res = HTTP::Response->new($status_code); $res->content_type('text/html'); #The following $content contains data within saved file pulled from we +b $res->content($content); #Let's push response back to client $self->proxy()->response($res);

I have the raw headers stored in a file, too, and that is what I really want to use rather than only using a
$res->content_type('text/html');

I want to read in the entire file and use it to replicate what was originally received by the server the file was pulled from. Here is a sample of one of the files:

Connection: close Date: Sat, 24 Oct 2009 02:55:24 GMT Accept-Ranges: bytes ETag: "580d7-3e3e-45861df8" Server: Apache/1.3.29 (Unix) PHP/4.3.4 Content-Length: 15934 Content-Type: image/gif Last-Modified: Mon, 18 Dec 2006 17:12:40 GMT Client-Date: Sat, 24 Oct 2009 03:48:49 GMT Client-Response-Num: 1

Something worth noting is that the header file may contain mulitple lines with the same 'xyz:' field on the left, such as 'Links:'.

I want to read the file into a variable and just use something like the following to set up for returning to client.

# $header_file_content contains information from raw header dump file $res->headers($header_file_content);

Thank you in advance for your help


In reply to Help building response headers for HTTP proxy request by r1n0

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.