Milen Nikolov via curl-library
2021-04-23 15:02:07 UTC
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
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