cURL / Mailing Lists / curl-library / Single Mail


Impossible to POST binary data with CURLOPT_POSTFIELDS

From: Spacen Jasset <>
Date: Thu, 11 Oct 2007 14:39:21 +0100

For libcurl 1.17.0

On August 1st url.c was changed (Revision 1.631) to make a copy of post
data so

that the caller need not keep the post buffer arround while curl operates,

unfortunatly this change has broken binary http posts since the code now
does a


See: Curl_setstropt

It isn't possible to remedy this and keep the new semantics. The options
for a fix

are therefore:

0) Revert the code to do what it did before and require the buffer to be

durring the action

1) As (0) and then add a new api to make a copy of the post data

** The following options would change the API and application compatability:

2) Change CURLOPT_POSTFIELDS to include a size parameter

3) Require CURLOPT_POSTFIELDSIZE to be called first

In my copy of libcurl I have done (3) for the moment, but I have not
proper fix as

it involved changing the api or adding a new one.

To reproduce

I used wireshark to monitor the network traffic, and stepping into the code.

char buffer[] = "only\0the first word will get sent.";
long size = sizeof buffer;

curl_easy_setopt(curl, CURLOPT_URL, "http://<any-server>");
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, buffer, size);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, size);
CURLcode result = curl_easy_perform(curl);
Received on 2007-10-11