Explaining how HTTP works might give you better understanding.
Basically a browser fetches a page (for arguments sake call it page.html) with a GET request (webserver sends as content-type text/html). It then analyzes the file for IMG tags, EMBED tags, background tags in TABLE and BODY, etc and it converts those relative filenames into full URLs (if relative filenames are used). Then it fetches those files one by one and
inserts em into the page. Text browsers like Lynx (which is libwww based, like
LWP::Simple etc) don't automagically fetch all files . They don't display images, play soundfiles or shockwave animations.
Bottom line is that your images are treated as images, thru the HTTP header the webserver sends, same header that is generated by your script. If your script doesn't generate a content-type header (or a invalid one for the data), the webserver doesn't know what content-type it is and neither does your browser. Regular files have valid content-type headers since that's
directly handled by the webserver.
There is a request for each file that needs to be downloaded. So you can't insert HTML tags in image/png data, since the HTML page was handled in a previous request (as content-type text/html). You can't mix different content-types in the same script call. Once the HTTP header is set, the remaining data is handled as belonging to that specific content-type data.
Hope this makes sense... This is only part of the HTTP protocol, things will get clearer once you're used to the basic stuff.
Note: There are ofcourse POST requests, but that's a whole new chapter.
If you want to know more about HTTP, you can check
RFC 2616, which are the specs for HTTP 1.1 (1.0 is still more commonly used but it'll give ya an idea). Ofcourse you can always just learn while you go, which is more fun.
Greetz
Beatnik
... Quidquid perl dictum sit, altum viditur.
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.