cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Setting proxy type using CURLOPT_PROXY?

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 23 Aug 2006 23:48:58 +0200 (CEST)

On Wed, 23 Aug 2006, Tillmann Steinbrecher wrote:

> the documentation is a bit unclear about setting the proxy
> protocol using CURLOPT_PROXY. First, it states:
> "The proxy string may be prefixed with [protocol]:// since any such
> prefix will be ignored", which is clear, but later, it says:
> "Starting with 7.14.1, the proxy host string can be specified the exact
> same way as the proxy environment variables, include protocol prefix"
>
> I'm not sure what to make of it. Can I set the proxy protocol this way, or
> can I not?

You could just try and see if it works! ;-)

But yes, the second paragraph is very confusingly written and I've just
changed it to instead say:

       Starting with 7.14.1, the proxy host string given in environment
       variables can be specified the exact same way as the proxy can
       be set with CURLOPT_PROXY: to include protocol prefix (http://) and
       embedded user + password.

> For convenience, I want to specify the entire proxy configuration in one
> string (e.g. read from config file). Does this work: curl_easy_setopt(curl,
> CURLOPT_PROXY, "socks5://user:pass_at_gatekeeper.mycompany.net");

Yes it should work except for that libcurl won't detect the type of the proxy
based on the given string.

> Or do I have to check manually if the string starts with "socks5" or
> whatever, and then use CURLOPT_PROXYTYPE?

Yes you do. I don't think socks5:// is any standard prefix for this, is it?

> Even if I have to do so, is it safe to assume that - even in future versions
> - libcurl will not be confused if the protocol is a string it doesn't know
> (e.g. "socks5")?

It is safe that it will continue to ignore the protocol part of _PROXY strings
as suddenly starting to care about it will break lots of existing apps and I
make an effort in introducing changes in manners that don't do that.

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2006-08-23