It will work for non-authenticated requests easy, but not for authenticated ones
#!/usr/bin/perl -- use strict; use warnings; use WWW::Mechanize 1.54; my $ua = WWW::Mechanize->new; $ua->add_handler("request_send", sub { $_[0]->content(''); $_[0]->du +mp; return }); $ua->add_handler("response_done", sub { $_[0]->content(''); $_[0]->du +mp; return }); my $uri = URI->new('http://jigsaw.w3.org/HTTP/Basic/'); $ua->credentials( $uri->host_port, qw' test guest guest '); $ua->get( $uri ); print "\n--- SPECIFY HOST MANUALLY ---\n"; my $host = $uri->host( $ua->res->header('Client-peer') ); $ua->get( $uri, Host => $host ); __END__ GET http://jigsaw.w3.org/HTTP/Basic/ Accept-Encoding: gzip User-Agent: WWW-Mechanize/1.66 (no content) HTTP/1.1 401 Unauthorized Connection: close Date: Tue, 05 Oct 2010 10:07:17 GMT Server: Jigsaw/2.3.0-beta2 WWW-Authenticate: Basic realm="test" Content-Length: 261 Content-Type: text/html;charset=ISO-8859-1 Client-Date: Tue, 05 Oct 2010 10:07:20 GMT Client-Peer: 128.30.52.72:80 Client-Response-Num: 1 Title: Unauthorized (no content) GET http://jigsaw.w3.org/HTTP/Basic/ Accept-Encoding: gzip Authorization: Basic Z3Vlc3Q6Z3Vlc3Q= User-Agent: WWW-Mechanize/1.66 (no content) HTTP/1.1 200 OK Connection: close Date: Tue, 05 Oct 2010 10:07:17 GMT ETag: "1lkdfte:qoguo8q8" Server: Jigsaw/2.3.0-beta2 Content-Length: 458 Content-Location: http://jigsaw.w3.org/HTTP/Basic/ok.html Content-Type: text/html Last-Modified: Sun, 25 Jun 2000 17:08:58 GMT Client-Date: Tue, 05 Oct 2010 10:07:20 GMT Client-Peer: 128.30.52.72:80 Client-Response-Num: 1 Title: Basic Authentication test page (no content) --- SPECIFY HOST MANUALLY --- GET http://128.30.52.72:80/HTTP/Basic/ Accept-Encoding: gzip Host: jigsaw.w3.org Referer: http://jigsaw.w3.org/HTTP/Basic/ User-Agent: WWW-Mechanize/1.66 (no content) HTTP/1.1 401 Unauthorized Connection: close Date: Tue, 05 Oct 2010 10:07:18 GMT Server: Jigsaw/2.3.0-beta2 WWW-Authenticate: Basic realm="test" Content-Length: 261 Content-Type: text/html;charset=ISO-8859-1 Client-Date: Tue, 05 Oct 2010 10:07:20 GMT Client-Peer: 128.30.52.72:80 Client-Response-Num: 1 Title: Unauthorized (no content) Error GETing http://128.30.52.72:80/HTTP/Basic/: Unauthorized at test +.pl line 20

In reply to Re^2: Stateful Browsing and link extraction with AnyEvent::HTTP by Anonymous Monk
in thread Async DNS with LWP by jc

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.