curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: POST Request with non-null-terminated string

From: Daniel Stenberg via curl-library <curl-library_at_cool.haxx.se>
Date: Fri, 23 Apr 2021 17:17:24 +0200 (CEST)

On Fri, 23 Apr 2021, 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.

Set CURLOPT_POSTFIELDSIZE to the size of the data and it will not do strlen()
to figure out the size.

I also just filed https://github.com/curl/curl/pull/6943 to clarify this
better.

-- 
  / daniel.haxx.se
  | Commercial curl support up to 24x7 is available!
  | Private help, bug fixes, support, ports, new features
  | https://www.wolfssl.com/contact/
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html
Received on 2021-04-23