Q
Q
qooke2019-04-16 20:40:44
PHP
qooke, 2019-04-16 20:40:44

How to correctly pass base64 post request to c++ using curl library?

I'm doing a post request to index.php file <?php echo $_POST["body"] ?>
In C++ using curl lib.
If you substitute just the string "body=123" - the result will be positive.
If I substitute the base64 code I need - the request breaks
5cb6131c0cdb2609492695.png
Here is a piece of code
5cb61353b9806043055972.png
Please help me solve the problem

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman, 2019-04-16
@qooke

https://curl.haxx.se/libcurl/c/curl_easy_setopt.html
there is C++ libcurl bindings
sources curl_easy_setopt wrapper over

static CURLcode vsetopt(struct Curl_easy *data, CURLoption option, va_list param)

in which your std::string postData turns into a pumpkin
case CURLOPT_POSTFIELDS:
    /*
     * Like above, but use static data instead of copying it.
     */
    data->set.postfields = va_arg(param, void *); // Тут <-----------------------<<<<
    /* Release old copied data. */
    (void) Curl_setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL);
    data->set.httpreq = HTTPREQ_POST;
    break;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question