Hi,
I am in dire need of help with respect to LWP::UserAgend Module.
While searching thru monks, i stumbled across your node and thought you will be able to help me.
I come to the question directly. I have a LWP code using which i am trying to access web page within my office LAN. But i am getting "500 Internal Server Error". The version of Perl with me is 5.6.1.
I give below my code (masking my credentials) :) and the output i got. Please look into it and gimme your comments
#!C:/perl/bin/perl.exe
use LWP::UserAgent;
use LWP::Debug qw(+);
use HTTP::Request::Common;
my $url= 'http://punsez138451d/L3NOCALM/default.aspx';
my $ua = new LWP::UserAgent(keep_alive => 1);
$ua->credentials('punsez138451d:80','',"MYDOMAIN\\username",'password'
+);
$request = GET $url;
print "--Performing request now...------------------\n";
$response = $ua->request($request);
print "--Done with request---------------------------\n";
if( $response->is_success) {
print $response->content;
} else {perl
print 'Error: ', $response->status_line, "\n";
print "===== Request Headers =====\n";
print $response->headers->as_string;
print "\n===== Response Headers ====\n";
print $response->headers->as_string;
print "\n===== Response Content ====\n";
print $response->content;
exit 1;
}
$contents = $response -> content();
#print $response->status_line(), "\n";
#print $response->headers()->as_string();
My output:
C:\Documents and Settings\venkatesan_G02\Desktop>perl lwp_test.pl
LWP::UserAgent::new: ()
--Performing request now...------------------
LWP::UserAgent::request: ()
LWP::UserAgent::send_request: GET http://punsez138451d/L3NOCALM/defaul
+t.aspx
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::Protocol::collect: read 762 bytes
LWP::Protocol::collect: read 894 bytes
LWP::Protocol::http::request: Keep the http connection to punsez138451
+d:80
LWP::UserAgent::request: Simple response: Unauthorized
LWP::Authen::Ntlm::authenticate: authenticate() has been called
LWP::Authen::Ntlm::authenticate: In first phase of NTLM authentication
LWP::Authen::Ntlm::authenticate: Returning response object with auth h
+eader:
Authorization NTLM TlRMTVNTUAABAAAAB7IAAA4ADgAgAAAACQAJAC4AAAB2ZW5rYXR
+lc2FuX0cwM
klORkxFVkVMMw==
LWP::UserAgent::request: ()
LWP::UserAgent::send_request: GET http://punsez138451d/L3NOCALM/defaul
+t.aspx
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::Protocol::collect: read 100 bytes
LWP::UserAgent::request: Simple response: Internal Server Error
--Done with request---------------------------
Error: 500 Internal Server Error
===== Request Headers =====
Connection: close
Date: Mon, 13 Apr 2009 18:15:25 GMT
Server: Microsoft-IIS/6.0
Content-Length: 100
Content-Type: text/html
Client-Date: Mon, 13 Apr 2009 18:15:19 GMT
Client-Peer: 4.33.37.49:80
Client-Response-Num: 2
MicrosoftSharePointTeamServices: 12.0.0.4518
Title: Error
X-Powered-By: ASP.NET
===== Response Headers ====
Connection: close
Date: Mon, 13 Apr 2009 18:15:25 GMT
Server: Microsoft-IIS/6.0
Content-Length: 100
Content-Type: text/html
Client-Date: Mon, 13 Apr 2009 18:15:19 GMT
Client-Peer: 4.33.37.49:80
Client-Response-Num: 2
MicrosoftSharePointTeamServices: 12.0.0.4518
Title: Error
X-Powered-By: ASP.NET
===== Response Content ====
<html><head><title>Error</title></head><body>The function requested is
+ not suppo
rted
</body></html>
Any help will be greatly appreciated!!!