cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-tracker mailing list Archives

[ curl-Bugs-1531838 ] uploads with chunked encoding broken if header specified

From: SourceForge.net <noreply_at_sourceforge.net>
Date: Mon, 31 Jul 2006 09:11:13 -0700

Bugs item #1531838, was opened at 2006-07-31 09:11
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=1531838&group_id=976

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Mark Lentczner (mark_lentczner)
Assigned to: Nobody/Anonymous (nobody)
Summary: uploads with chunked encoding broken if header specified

Initial Comment:
Consider this sequence:

curl_easy_setopt(new_req->mCurlHandle, CURLOPT_UPLOAD, 1);

headers = curl_slist_append(headers, "Transfer-Encoding: chunked");
curl_easy_setopt(mCurlHandle, CURLOPT_HTTPHEADER, headers); if

curl_easy_setopt(new_req->mCurlHandle, CURLOPT_READFUNCTION,
                    &myUploadCallback);

// don't set CURLOPT_INFILESIZE

This causes libCURL to announce the request body (the upload) as
chunked, but then to not chunk encode the buffers from the callback.

The bug is in http.c, starting with the line:

if(!conn->bits.upload_chunky && (httpreq != HTTPREQ_GET)) {
...
}
else if(conn->bits.upload_chunky) {
    ....
    if(!checkheaders(data, "Transfer-Encoding:")) {
        te = "Transfer-Encoding: chunked\r\n";
    }
    else {
        te = "";
        conn->bits.upload_chunky = FALSE;
    }
}

As currently written, the logic runs like this:

if the upload is chunk (as the CURLOPT_INFILESIZE is not specified)
  if there is no transfer-encoding header
    set the transfer-encoding to chunked
  else (there is a transfer-encoding header
    set the transfer-encoding to ""
    turn off chunked

This second if should probably be something like:

ptr = checkheaders(data, "Transfer-Encoding:");
if(!ptr || Curl_compareheader(ptr, "Transfer-Encoding:", "chunked") {

So the logic is more like:

  if there no transfer-encoding header, or if it is chunked
    set the transfer-encoding to chunked
  else (there is a transfer-encoding header and it isn't chunked)
    set the transfer-encoding to ""
    turn off chunked

markl_at_lindenlab.com

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=1531838&group_id=976
Received on 2006-07-31

These mail archives are generated by hypermail.

donate! Page updated November 12, 2010.
web site info

File upload with ASP.NET