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.
POST Request with non-null-terminated string
- Contemporary messages sorted: [ by date ] [ by thread ] [ by subject ] [ by author ] [ by messages with attachments ]
From: Milen Nikolov via curl-library <curl-library_at_cool.haxx.se>
Date: Fri, 23 Apr 2021 17:02:07 +0200 (CEST)
Hi everyone,
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?
Best Regards,
Milen
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.se/mail/etiquette.html
Received on 2021-04-23
Date: Fri, 23 Apr 2021 17:02:07 +0200 (CEST)
Hi everyone,
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?
Best Regards,
Milen
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.se/mail/etiquette.html
Received on 2021-04-23