Thank you very much for the response! :-)
I have a follow on question before I try what you sent. For the response code:
if (-s $cache_path) { # is it in the cache?
# this would of course be the content read from the cache
+file...
my $content = "<html><body>...yadda yadda...</body></html>
+";
# create response
my $res = HTTP::Response->new(200);
$res->content_type('text/html');
$res->content($content);
# send back (short-circuit normal content fetching)
$self->proxy()->response($res);
}
I would like to know how I can assign the contents of an entire file to the HTTP::Reponse. The response will have the necessary header fields in it if I can just throw the entire file back to the client.
I might need to through my own response code, but that will be easy enough.
I would prefer not to have to read in all of the original headers and assign to each component of HTTP::Response, if I can avoid it.
Thanks in advance for your help.
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.