cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: proxy tunnel and custom headers

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Sun, 25 Jul 2010 00:25:00 +0200 (CEST)

On Sun, 25 Jul 2010, Patricia Muscalu wrote:

>>> Content-Disposition: attachment; filename="image.jpg"

>> Is that a bit like a multipart formpost? That last header looks unusual to
>> me.
>
> It is described by http://www.ietf.org/rfc/rfc2183.txt

Right, but I never see anyone trying to use this header in requests, I only
ever see servers send this header back in responses...

>> The file tests/libtest/lib510.c shows how we test POST using
>> Transfer-Encoding: chunked, but as you can see it _does_ set the header
>> manually! Is this similar to what you do, but you also use CONNECT through
>> a proxy (that then gets the Transfer-Encoding: header) ?
>
> Thank you for your advice. I have looked into the suggested example.
> Depending on the digest option and the transfer type I've got the following
> results:
>
> 1. CURLAUTH_DIGEST + transfer chunked just hangs my HTTP server.

Using what libcurl version? I'm suspecting this is the bug we fixed just a
little while ago.

> 2. CURLAUTH_ANY + transfer chunked combination results in:
>
> * About to connect() to 192.168.0.1 port 8080 (#0)
> * Trying 192.168.0.1... * connected
> * Connected to 192.168.0.1 (192.168.0.1) port 8080 (#0)
>> POST /cgi-bin/upload.cgi HTTP/1.1
> Host: 192.168.0.1:8080
> Accept: */*
> Transfer-Encoding: chunked
> Content-Type: application/x-www-form-urlencoded
>
> data: one, len:3
> data: two
> , len:3
> data: three, len:5
> data: and a final longer crap: four, len:29
> < HTTP/1.1 401 Authorization Required
> < Date: Sat, 24 Jul 2010 21:58:58 GMT
> < Server: Apache/2.2.14 (Unix) mod_ssl/2.2.14 OpenSSL/0.9.8g
> < WWW-Authenticate: Digest realm="RealmXXX",
> nonce="7gUvQimMBAA=06b8c52058f521fa4d9117f878aa4d4314790b04", algorithm=MD5,
> qop="auth"
> < Content-Length: 401
> < Content-Type: text/html; charset=iso-8859-1
> * necessary data rewind wasn't possible
> * Closing connection #0
> * Send failed since rewinding of the data stream failed

This is a flaw in your application. When you send data using "any" method,
libcurl will (most likely) need to rewind the data when it has sent off a part
or all of it. libcurl rewinds using a callback, and you're adviced to provide
one with CURLOPT_SEEKFUNCTION.

> 3. Disabling transfer chunked gives the Content-Length: 0 header.

Well, in that case there is no known size so I don't think you should expect
that to do the right thing automagically.

The biggest missing feature I think here is that there's no way to ask libcurl
to do chunked encoding in its uploading/sending without setting the custom
header.

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