cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Auto-proxy configuration option for curl?

From: Cris Bailiff <c.bailiff_at_awayweb.com>
Date: Tue, 07 Aug 2001 09:21:07 +1000

One approach which ends up roughly similar to the javascript script is to use a
set of perl patterns (regular expressions) to set your proxy:

my $proxy;
SWITCH: for ($url) {
        m!^http://intranet\.othercompany\.com/! && do { $proxy="proxy.othercompany.com";
last SWITCH }
        m!^http://10\(.\d{1,3}){3}/! && do { $proxy="10.2.1.1"; last SWITCH }
        m!^http://(.*\.company\.com|localhost)/ && do { $proxy=""; last SWITCH }
        $proxy="proxy.company.com";
}

if ($proxy) { $ENV{HTTP_PROXY}=$proxy } else { delete $ENV{HTTP_PROXY} };

autoproxy files often use javascript regexes anyway - if its well written, you
can almost translate straight to perl, perhaps even using s/// ?!

Trying to add a whole javascript interpreter to curl or perl is a loosing path
though...

Cris

"Halliburton, Pat" wrote:
>
> Actually, I guess it is Java but the same issue exists, how to pull it in
> and use it or convert it to something that can be used. I have some access
> to the people who are creating it, so perhaps I can try talking them into
> producing another copy of it in a table or some other easily recognizable
> format which I can dynanically ftp and interrogate for my app's use.
>
> Thanks for pointing me in the right direction.
>
> Regards,
> Pat
>
> -----Original Message-----
> From: Halliburton, Pat
> Sent: Monday, August 06, 2001 4:56 PM
> To: 'curl_at_contactor.se'
> Subject: RE: Auto-proxy configuration option for curl?
>
> Well, it seems to be a Perl function instead of Java and I can see what
> it's doing. However, I'm sure it's subject to change since it contains
> specific urls, domains, etc. that need special handling (that's the whole
> point I guess.) So the issue becomes how to keep up with the changes
> dynamically
> or at least without a lot of manual effort.
>
> Regards,
> Pat
>
> -----Original Message-----
> From: Roth, Kevin P. [mailto:KPRoth_at_MarathonOil.com]
> Sent: Monday, August 06, 2001 3:48 PM
> To: curl_at_contactor.se
> Subject: RE: Auto-proxy configuration option for curl?
>
> An "auto-proxy" script is really just a piece of JavaScript. It's a
> function that your browser calls to figure out what proxy settings to
> use for a specific URL. I'm gonna guess that it would be quite a stretch
> to change curl to be able to run this code.
>
> You can actually type the auto-proxy URL into your browser's address
> bar, and view the JavaScript code. Your browser calls the function in
> there, and passes it the hostname and URL that it's getting ready to
> obtain, and the code should return the proxy setting to use. Either
> "PROXY hostname:port" or "DIRECT", or "SOCKS ...".
>
> Once you know which URLs need to go through a PROXY and which don't, it
> should be possible to re-code that logic into your Perl script to set
> PROXY options on a per-connection basis.
>
> --Kevin
>
> -----Original Message-----
> From: Halliburton, Pat [mailto:phalliburton_at_ti.com]
> Sent: Monday, August 06, 2001 3:12 PM
> To: 'curl_at_contactor.se'
> Subject: Auto-proxy configuration option for curl?
>
> I have a Perl script which calls Curl as a commandline utility on
> Solaris.
> Currently, I'm using environment variables HTTP_PROXY, HTTPS_PROXY and
> NO_PROXY to set protocol specific proxy settings. This script basically
> just uses Curl to test a set of intranet and internet url's, ie. can
> they be
> accessed successfully or not. This method of proxy cofiguration works
> fine
> for most urls. However, there are some urls which consistently fail
> using
> these proxy setttings yet work fine in my workstation browsers if I use
> an
> "auto-proxy" configuration url option instead of setting specific
> protocol
> proxy server setttings. I'd like to use this "auto-proxy" option with
> curl
> but am having trouble finding any curl doc that describes how to do
> that.
> There is a mention of another environment variable: ALL_PROXY. Is that
> what I need, ie. just set to the url which I use for the auto-proxy
> settings
> in my workstation browsers? Or is there some curl commandline option
> which
> allows me to specify this?
>
> Regards,
> Pat

Received on 2001-08-07