Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

https request failing

by bethereu2 (Initiate)
on Sep 18, 2012 at 11:09 UTC ( #994262=perlquestion: print w/replies, xml ) Need Help??
bethereu2 has asked for the wisdom of the Perl Monks concerning the following question:


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

Replies are listed 'Best First'.
Re: https request failing
by marto (Archbishop) on Sep 18, 2012 at 11:20 UTC

    If $url works from a browser but not from your script check to see that there's no proxy in between (the 8080 part). Does this show up as an environment variable (HTTP_PROXY/HTTPS_PROXY)? If so consider removing the trailing slash from "8080/"

      Hi, I checked the env params:
      env | grep proxy http_proxy=http://<company-proxy>.se:8080/ https_proxy=http://<company-proxy>.se:8080/ no_proxy=localhost,, .<companyname>.se,
      In the perl script I used: no_proxy() should not proxy be skipped?
      br, //mike

        That's worth investigating, but I'll leave that to you. Regardless I think the trailing slash may cause problems, which is why I suggested removing it.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://994262]
Approved by Ratazong
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2018-05-26 18:36 GMT
Find Nodes?
    Voting Booth?