cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: proxy tunnel and custom headers

From: Patricia Muscalu <ppatriciatl1_at_gmail.com>
Date: Thu, 22 Jul 2010 22:55:02 +0200

On Thu, Jul 22, 2010 at 10:24 PM, Dan Fandrich <dan_at_coneharvesters.com>wrote:

> On Thu, Jul 22, 2010 at 09:58:41PM +0200, Patricia Muscalu wrote:
> > How do I prevent Transfer-Encoding header from being included in the
> CONNECT
> > request?
> > The following combination of curl options will hang the proxy:
> >
> > curl_easy_setopt (curl, CURLOPT_HTTPPROXYTUNNEL, 1L);
> > chunk = curl_slist_append(chunk, "Transfer-Encoding: chunked");
> > curl_easy_setopt(curl, CURLOPT_HTTPHEADER, chunk);
> > curl_easy_setopt (curl, CURLOPT_PROXY, "localhost");
> > curl_easy_setopt (curl, CURLOPT_PROXYPORT, 7777);
> > curl_easy_setopt (curl, CURLOPT_PROXYAUTH, CURLAUTH_ANY);
> > curl_easy_setopt (curl, CURLOPT_PROXYUSERNAME, "proxyuser");
> > curl_easy_setopt (curl, CURLOPT_PROXYPASSWORD, "proxypasswd");
>
> You shouldn't need to set the Transfer-Encoding header yourself. curl will
> take care of setting it correctly as needed.
>

Thank you for your answer!

Without supplying Transfer-Encoding header, curl sets Content-Length: -1.

Giving more details, I send as well the following headers to the HTTP
server:
Content-Type: image/jpeg
Content-Disposition: attachment; filename="image.jpg"

The application receives media data on the fly (data length is unknown at
the moment of starting the request)
and sends this data as a jpeg file.
Temporarily, I send Content-length: 0 header with the CONNECT request and
wait for the 200 Connection Established response
from the proxy. After the proxy tunnel has been established, I set
Transfer-Encoding header plus other custom headers according to:
if (response == 200) {
  curl_multi_remove_handle
  set_custom_headers
  curl_multi_add_handle
}

Is this a correct approach? Is there any other way of achieving
this behavior?

Thank you for any answers!

>
> >>> Dan
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette: http://curl.haxx.se/mail/etiquette.html
>

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-07-22