cURL / Mailing Lists / curl-library / Single Mail


Curl_readrewind and form data

From: Joshua Kwan <>
Date: Sun, 29 Sep 2013 15:08:37 -0700 (PDT)

Hey all,

Been a while, hope you remember me. :)

We're using cURL these days to do a POST of form data. When combined with proxy authentication and ANYAUTH behavior, there's a bug with rewinding the input data. Here's some source snippets:

      if (curl_formadd(&xfer->uploadForm, &formLast,
                       CURLFORM_COPYNAME, fieldName,
                       CURLFORM_FILENAME, fileName,
                       CURLFORM_STREAM, xd, // a pointer to an internal structure that is supported by our READFUNCTION
                       CURLFORM_CONTENTSLENGTH, len,
                       CURLFORM_END) != 0) {
         goto out;

When sending this using ANYAUTH and receiving a 407, we try again after setting the proper proxy credentials, but the file is already completely read from the first request and not rewound due to this code, so the attachment is blank. We thought it was because we don't have a SEEKFUNCTION, but defining it did not help because of the logic in Curl_readrewind.

Is there any reason *not* to rewind the file in this situation?


List admin:
Received on 2013-09-30