I do this exact task myself with an image metadata crawler I wrote. The steps are:

1) Connect to the network socket (S)

2) Turn buffering in the socket off with select(S); $| = 1; select(STDOUT);

3) Send request to server:

$result = eval 'print S "GET /$document HTTP/1.1\nHost: $server_host\n\n"';

4) Read <S> up to the end of the HTTP header (and verify that you have the expected Content-type).

5) Call Image::ExifTool::ImageInfo(\*S, {FastScan => 1}) to read the metadata.

ExifTool will only read as much of the file as necessary to obtain the metadata (the FastScan option prevents reading to the end of the image to look for a metadata trailer).

- Phil

In reply to Re: How to download JUST the first X bytes of HTTP response ? by boardhead
in thread How to download JUST the first X bytes of HTTP response ? by Anonymous Monk

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.