I'm using libcurl to POST form data using a FILE* with the CURLFORM_STREAM option of curl_formadd(). I've noticed that if the connection drops at just the right time, the POST is reattempted without the data from the file. It seems like the file stream position isn't getting reset to the beginning of the file. I found the CURLOPT_SEEKFUNCTION option and set that with a function that performs an fseek() on the FILE*. However, setting that didn't seem to fix the issue or even get called.
It seems like Curl_retry_request() has to get hit so that Curl_readrewind() is called (at least for my scenario). When Curl_readrewind() is called, the current logic prevents the CURLOPT_SEEKFUNCTION from getting called with a CURLFORM_STREAM.
I've attached a test client & server that's the closest I could get to the scenario I'm facing. Since it's a race condition whether or not the seek function is needed (depends on when the TCP session ends), it takes a lot of cycles of the test client to get the issue to occur. However, on my PC (Ubuntu 14.04 with an AMD Phenom II X4 B55 @ 3.2 GHz), I can get the issue to occur every time with the current number of test cycles set in the client.