cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Content-Length header on CONNECT requests

From: Mark Aldred <mark_at_twinstrata.com>
Date: Tue, 26 Jun 2012 16:33:46 -0400

On Tue, Jun 26, 2012 at 9:12 AM, Mark Aldred <mark_at_twinstrata.com> wrote:
>> When using a proxy and issuing a request that contains a
>> content-length header, lib-curl includes the content-length header in
>> the CONNECT request (if a CONNECT is needed).  Some proxies reject
>> this with a 400 (Bad Request).  I have seen it with Bluecoat.   This
>> seems like a bug in curl.  Other than changing the curl code, how can
>> I avoid this?
>
> It is a bug, yes. We should make sure it doesn't send such headers!
>
> The work-around for now would be to _not_ send content-length in custom
> headers - that is usually a bad idea anyway.
>
> Will you be able to provide a patch for this problem?
>
> --
> / daniel.haxx.se

Here is the fix based on 7.25.0. Don't include any custom headers
with a CONNECT request.

--- http_proxy.c 2012-06-26 16:22:52.111678082 -0400
+++ http_proxy.c.fix 2012-06-26 16:23:01.863677869 -0400
@@ -206,9 +206,6 @@
         free(hostheader);

         if(CURLE_OK == result)
- result = Curl_add_custom_headers(conn, req_buffer);
-
- if(CURLE_OK == result)
           /* CRLF terminate the request */
           result = Curl_add_bufferf(req_buffer, "\r\n");

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-06-26