I tried to send this by mail to petdance, but a spam filter refuses to accept my email.

Well, I think I found a bug.

$mech->get($url); for $img ($mech->images) { # $mech->head($img->url_abs()); # $mech->back(); $mech->get($img->url_abs()); $mech->back(); }

What I want to do is to request every image with the page's URL as the referrer. That code works as expected, except when I remove the comment hashes to request the headers first. Then, the URL used by head() is sent by get() as the referrer, even after calling back() before it, which also fails with the first embeded image. Also the same URL is used as referrer by head() for the second image.

I've set up a working example for $url at: <http://www.vitoco.cl/test-ref>

My complete script is at: <http://www.vitoco.cl/test-ref/test-ref.pl>

First, I thought it was an issue about multiple redirections of the images, but discarded this idea using this other test page with direct links: <http://www.vitoco.cl/test-ref/index2.html>

I used a local proxy to capture HTTP headers.

If I'm doing something wrong, please let me know.

Thanks... ++Vitoco


In reply to Referer and HEAD using WWW::Mechanize by vitoco

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.