Hi,

On 23.04.2021 at 17:02, Milen Nikolov via curl-library wrote:

> I'm using libcurl in C++ and I have to make a post request to a server, 
> containing a string in the body section. Another -condition is that I have to 
> specify the content-type as octet-stream. I've set the header, authentication 
> and so on, but there is one problem: the curl function (CURLOPT_POSTFIELDS) 
> takes as argument a c-string. In my string there are also NUL characters, 
> which have to be sent. When I try sending the request the body is truncated 
> at the first NUL chararcter. I've tried saving my string in a char array and 
> then providing it as an argument, but this didn't solve the issue, although 
> if I try to print out chars after the first NUL in the console, they print 
> out fine. So my question is if there's a workaround, which will allow me to 
> solve the issue or is it impossible due to the fact that curl is a C library 
> and the null-terminated strings are the C standard?

Did you try to set the desired length with CURLOPT_POSTFIELDSIZE?

--
Christoph M. Becker

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html

Reply via email to