Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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:

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

Comment on https request failing
Download Code
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, 127.0.0.1, .<companyname>.se, .company.com
      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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://994262]
Approved by Ratazong
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (15)
As of 2015-07-31 14:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (278 votes), past polls