libcpr / cpr

C++ Requests: Curl for People, a spiritual port of Python Requests.
https://docs.libcpr.org/
Other
6.59k stars 937 forks source link

how to use Interceptor change the post body #883

Closed vanehu closed 1 year ago

vanehu commented 1 year ago

form data or value must be encode, is there any way to do this . it cat reduce more code

COM8 commented 1 year ago

You can use this function:

https://github.com/libcpr/cpr/blob/0817715923c9705e68994eb52ef9df3f6845beba/cpr/util.cpp#L162-L165

Something like this should work:

#include <cpr/util.h>
#include <string>

void foo() {
    std::string in = "input";
    std::string out = cpr::urlEncode(in);
}