json::value obj;
obj[L"title"] = json::value::string(U("count1"));
obj[L"num"] = json::value::number(1);
wcout << obj << endl;
// Create http post request
http_client client(U("http://localhost:3000/count"));
http_request request(methods::POST);
request.headers().add(L"Content-Type", L"application/json; charset=UTF-8");
request.headers().add(L"Content-Length", L"100");
request.headers().add(L"Host", L"testhost.com");
request.headers().add(L"X-Requested-With", L"XMLHttpRequest");
request.set_body(obj);
// Interpretation of response to request
auto resp = client.request(request).get();
wcout << U("STATUS : ") << resp.status_code() << endl;
wcout << "content-type : " << resp.headers().content_type() << endl;
wcout << resp.extract_string(true).get() << endl;
I have a question about L"~~~~" while I was sending json data by making a post request on C++ as follows.
I think it's like a format, but I want to know in detail.
c++ http
Note Link for more information.
L'..If an L is attached to a prefix, such as '
or 'L"...'<
, it is to declare the use of characters expressed in multi-byte, such as Korean. (It's usually called a wide character.))
© 2024 OneMinuteCode. All rights reserved.