Oct 242013
Article Perl

A previous post in this blog explains How to fetch the content of a URL in perl,   using the LWP::UserAgent module available from CPAN.

But it might happen that the machine where the script is going to be run does not have direct access to internet, and the request must be sent through a proxy servere. This post explains how to make the request in this case.

The LWP::UserAgent module implements a “proxy()” method that can be used to configure the proxy to be used to establish the connection:

Connecting to a proxy with user validation

If the proxy requires user validation, the username and password can be added to the url itself, as follows:

Using environment variables to specify the proxy

Alternatively, the proxy server, username and password can be specified by means of environment variables:

Connecting to a  proxy with HTTPS

If the proxy requires a secure HTTPS connection, environment variables specific for this protocol can be used:

Index of posts related to perl programming

 Posted by at 12:18 pm

 Leave a Reply