bowei_99 has asked for the wisdom of the Perl Monks concerning the following question:

I have code that downloads a Tomcat web page. When I run the code below, it replaces the port 8082 with 80, causing it to timeout. Is there a way in HTTP::Request to use my port instead? I looked at the doc on cpan, but found nothing on the port.

I'm hoping not to have to use SOAP::Lite, as it would seem overkill. I only have to check that the http protocol is available on the port I specify. Telnetting to the port should work, in theory, but I'd really rather prefer something that gets a real HTTP response.

use LWP; use HTTP::Request; my $req = HTTP::Request->new(GET => 'http://ip-address/axis2/services/ +Service1:8082'); my $ua = LWP::UserAgent->new; my $res = $ua->request($req); if (($res->is_success) or ($res->status_line =~ /404 Not Found/)){ print "HTTP OK - connected\n\n"; } else { print "HTTP ERROR " . $res->status_line, " \n\n"; }

-- Burvil

Replies are listed 'Best First'.
Re: Why does HTTP::Request change the port I specify?
by moritz (Cardinal) on Apr 13, 2008 at 16:44 UTC
    You're writing the port number in the wrong place. It should go directly after the IP, http://ip-address:8082/acis2/servies/Servic1.
Re: Why does HTTP::Request change the port I specify?
by Corion (Patriarch) on Apr 13, 2008 at 16:45 UTC

    That's not how you specify the port. See RFC 1738, section 3.3, "HTTP".

    An HTTP URL takes the form:
    http://<host>:<port>/<path>?<searchpart>