Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Dear perl gurus:

I am humbly asking you for your assistance. I was trying to use LWP::UserAgent to go to a password protected ASP page (my login/password works fine with IE browser). The code I have written is like this:

my $h = new HTTP::Headers Content_Base => '$url'; $h->authorization_basic($uname, $password); my $request = HTTP::Request->new( 'GET', $url, $h ) ; my $ua = LWP::UserAgent->new; my $response = $ua->request($request); ### get content of this HTML $content = $response->content; #print $content;

These lines work well with other web pages written in CGI but it did not work for a link written in ASP. Here is the error I got from the run:
"HTTP 401.2 - Unauthorized: Logon failed due to server configuration Internet Information Services".

The returned HTML also suggested:
"This is usually caused by a server-side script not sending the proper WWW-Authenticate header field. Using Active Server Pages scripting this is done by using the AddHeader method of the Response object to request that the client use a certain authentication method to access the resource."

So, it hinted that something might need to be done on the server side. However, since I don't have control/contract from the server hosting this link, is there any ways that I can solve this problem from my end? Any suggestions or tips will be highly appreciated!



In reply to Use LWP::UserAgent to go to a password protected ASP page by Puma_perl

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others drinking their drinks and smoking their pipes about the Monastery: (4)
    As of 2020-06-01 23:26 GMT
    Find Nodes?
      Voting Booth?
      Do you really want to know if there is extraterrestrial life?

      Results (12 votes). Check out past polls.