cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re[2]: Working with curl connections as with sockets.

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 29 Apr 2008 00:06:33 +0200 (CEST)

On Mon, 28 Apr 2008, Tetetest wrote:

> Currently, if you use this option, curl_easy_perform() returns immediately
> after it connects to the proxy. It leaves you with the socket that is
> basically unusable: you must perform the proxy negotiation yourself. So,
> CURLOPT_CONNECT_ONLY should connect you THROUGH the proxy, and not TO the
> proxy.

Are you *sure* this is what happens? The whole purpose and idea when this
option was added was exactly this "THROUGH the proxy" you mention and I have
in fact used it like that myself in the past.

> Currently, proxy negotiation is added to every supported protocol
> individually (correct me if I'm wrong here, but I didn't see any proxy
> support in, say, tftp.c or telnet.c).

Right, but the proxy connection code is not specific to the protocols so it is
easy to add, once anyone wants it. I'm not a believer in doing fancy things in
preparation for future possible needs. I rather wait until the need and desire
actually pop up and then we act accordingly! (TFTP is udp so that's hard to do
over a HTTP CONNECT reqest!)

But you're not talking about using any of these protocols, you want recv and
send, so why is this a concern now?

> So I have two options:
>
> - introduce some imaginary "protocol" that will be used together with
> CURLOPT_CONNECT_ONLY to establish a connection through proxy.
> Moreover, such a protocol could automatically set
> CURLOPT_CONNECT_ONLY option: getting "raw://www.google.com:80/"
> would connect to google via your proxy and return.
> The downside of this approach is clear: one more protocol means that
> you have more things to synchronize when adding new features.
>
> - Or, use existing protocol with good support for proxies (e.g., HTTP);
> add minor modifications that will check that set.connect_only ==
> TRUE, and cause the handler to stop transfer as soon as the
> connection through proxy is established.
>
> Clearly, I better like the second approach. I have checked it with some
> proxies out there, and it works. Besides, it requires fewer modifications to
> the code.

The latter is already how the code works, or at least is supposed to work so
yes that should be very little code changes needed.

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2008-04-29