https request failing

M

mike

Hi,

The script I have below is used o access an internal website with https (so no proxy here).

use LWP::UserAgent;
use LWP::Debug qw(+);

#create User-agent
my $ua = LWP::UserAgent->new;

$ua->no_proxy("<internalsite>.se");


my $url = "http://<internalsite>.se/org.testng.eclipse/site.xml";

my $req = HTTP::Request->new(
GET => $url);


# send request
my $res = $ua->request($req);

# check the outcome
if ($res->is_success) {
print $res->decoded_content;
}
else {
print "Error: " . $res->status_line . "\n";
}

When I execute it I get the following error:

LWP::UserAgent::new: ()
LWP::UserAgent::request: ()
LWP::UserAgent::send_request: GET http://<internalsite>.se/org.testng.eclipse/site.xml
LWP::UserAgent::_need_proxy: Not proxied
LWP::protocol::http::request: ()
LWP::protocol::collect: read 259 bytes
LWP::UserAgent::request: Simple response: Found
LWP::UserAgent::request: ()
LWP::UserAgent::send_request: GET https://<internalsite>.se/org.testng.eclipse/site.xml
LWP::UserAgent::_need_proxy: Not proxied
LWP::protocol::http::request: ()
LWP::UserAgent::request: Simple response: Internal Server Error
Error: 500 Can't connect to <internalsite>.se/:443 (Bad service '8080/')

Any ideas what the problem can be?

br,

//mike
 
M

mike

Just a quick note. If I put the url in mozilla I can see the content:

<site><description url="http://beust.com/eclipse-old/eclipse-6.3.2.20111203_1323/index.html"/><feature url="features/org.testng.eclipse_6.3.2.20111203_1323.jar" id="org.testng.eclipse" version="6.3.2.20111203_1323"><category name="org.testng.eclipse"/></feature><category-def name="org.testng.eclipse" label="TestNG">
</category-def></site>

br,

//Mike
 
D

Dr.Ruud

use LWP::UserAgent;
use LWP::Debug qw(+);

#create User-agent
my $ua = LWP::UserAgent->new;

$ua->no_proxy("<internalsite>.se");


my $url = "http://<internalsite>.se/org.testng.eclipse/site.xml";

The cut lines can be replaced by:

my $res= $ua->get( $url );
# check the outcome
if ($res->is_success) {
print $res->decoded_content;
}
else {
print "Error: " . $res->status_line . "\n";
}

Also print Dumper( $res ) for details.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top