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.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.