Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

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 (Bishop) 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 the leaves swirl about...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2018-01-17 01:29 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (194 votes). Check out past polls.