How do I know if a site is prompting me with basic authentication? I am attempting to use LWP to do basic authentication and for some reason it is not working.
Running the the following script:
use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
use strict;
my $ua = LWP::UserAgent->new();
my $req = POST 'http://home.sff.net/login.asp', [ username => 'jonatha
+nmark', RecordID => 4142];
print "The netloc is" , $req->url->netloc, ". ";
$ua->credentials($req->url->netloc, "home.sff.net", 'jonathanmark', 'n
+ottherealpassword');
my$content = $ua->request($req)->as_string;
print "Content is $content";
produces the following output:
The netloc is: home.sff.net. Content is HTTP/1.0 401 (Unauthorized) Ac
+cess Denied
Cache-Control: private
Date: Fri, 01 Mar 2002 01:46:04 GMT
Via: 1.1 Dyn-EH-NetCache (NetCache NetApp/5.1R2)
Server: Greyware Web Server
WWW-Authenticate: Basic realm="home.sff.net"
Content-Length: 24
Content-Type: text/html
Client-Date: Fri, 01 Mar 2002 01:48:51 GMT
Client-Peer: 208.14.208.55:80
Error: Access is Denied.
If anyone has any idea I would really appreciate it.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.