microsoft / cpprestsdk

The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.
Other
7.96k stars 1.65k forks source link

can't get the json value with linux server and windows client #1661

Closed ZhangTaiwen closed 2 years ago

ZhangTaiwen commented 2 years ago

build the http client with windows execute program, and run rest server on linux (centos 8) when client send a request with json value in the http body, the rest server will be hung when call request.extract_json().get(), it is hung in get() call,

both the http client and server run on linux(cent os8) with execute program, the rest server on linux won't hung both the http client and server run on windows(win7) with execute program, the rest server on windows won't hung if the rest server run on linux, and the http request sent by postman, the rest server won't hung

Thanks

ZhangTaiwen commented 2 years ago

client code:

http_client client(U("http://192.168.17.70:8080"));

json::value Request;

Request = json::value("test12345678");

method mtd = methods::PUT;//methods::POST;

http_request msg(mtd);

msg.set_body(Request);

http::http_response response;

try
{
    printf("sent request\n");
    response = client.request(msg).get();
}
catch (std::exception& ex)
{
    printf("exception\n");
    return -1;
}

printf("get response\n");

http::status_code ret = response.status_code();

server code:

void HttpHandler(http_request request) { json::value jReqData; json::value jRespData;

try
{
    jReqData = request.extract_json().get();// hung htere on linux if request send by windows client

    request.reply(status_codes::OK).wait();
ZhangTaiwen commented 2 years ago

not an issue, problem solved