First step is first, find out what actually gets sent, then duplicate it

$ lwp-request -USEd -H "Referer: http://localhost" http://example.com GET http://example.com Referer: http://localhost User-Agent: lwp-request/6.15 libwww-perl/6.15 200 OK Cache-Control: max-age=604800 Connection: close Date: Sun, 29 Jan 2017 23:41:21 GMT ETag: "359670651+ident" Server: ECS (rhv/818F) Vary: Accept-Encoding Content-Length: 1270 Content-Type: text/html Expires: Sun, 05 Feb 2017 23:41:21 GMT Last-Modified: Fri, 09 Aug 2013 23:54:35 GMT Client-Date: Sun, 29 Jan 2017 23:55:28 GMT Client-Peer: 93.184.216.34:80 Client-Response-Num: 1 Title: Example Domain X-Cache: HIT X-Ec-Custom-Error: 1 X-Meta-Charset: utf-8 X-Meta-Viewport: width=device-width, initial-scale=1

The referer does get sent , but its just one header, and webservers can be stupidly specific in what headers they like

use WWW::Mechanize; my $ua = WWW::Mechanize->new; $ua->get('http://example.com', 'Referer', 'localhost'); print $ua->res->request->headers_as_string; print $ua->res->headers_as_string; __END__ Accept-Encoding: gzip Referer: localhost User-Agent: WWW-Mechanize/1.78 Cache-Control: max-age=604800 Connection: close Date: Sun, 29 Jan 2017 23:45:39 GMT Accept-Ranges: bytes ETag: "359670651" Server: ECS (rhv/818F) Vary: Accept-Encoding Content-Encoding: gzip Content-Length: 606 Content-Type: text/html Expires: Sun, 05 Feb 2017 23:45:39 GMT Last-Modified: Fri, 09 Aug 2013 23:54:35 GMT Client-Date: Sun, 29 Jan 2017 23:59:46 GMT Client-Peer: 93.184.216.34:80 Client-Response-Num: 1 X-Cache: HIT X-Ec-Custom-Error: 1

In reply to Re: Need LWP::UserAgent --header help by Anonymous Monk
in thread Need LWP::UserAgent --header help by Todd Chester

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.