亚欧色一区w666天堂,色情一区二区三区免费看,少妇特黄A片一区二区三区,亚洲人成网站999久久久综合,国产av熟女一区二区三区

  • 發布文章
  • 消息中心
點贊
收藏
評論
分享
原創

cpprestsdk編譯安裝使用

2024-04-30 09:17:41
102
0

CPP REST SDK是微軟開源的基于PPL的異步http client,網絡層使用的是Boost.Asio,跨平臺,并且支持json解析,在使用CPP REST SDK之前要確保已經安裝了boost和openssl

安裝boost和openssl

yum install boost-devel -y
yum install openssl-devel -y

安裝cpprestsdk

git clone https:斜杠github.com/microsoft/cpprestsdk
cd cpprestsdk
git submodule update --init
mkdir build && cd build
cmake ..
make -j4
make install

報錯:

cpprestsdk/Release/tests/functional/http/listener/listener_construction_tests.cpp:529:17: error: ‘class boost::asio::ssl::context’ has no member named ‘use_certificate_chain’; did you mean ‘use_certificate_file’?

原因:yum安裝boost只有1.53版本,要手動安裝1.63.0版本

解決:手動安裝boost

源碼下載:https:斜杠boostorg.jfrog.io/artifactory/main/release/
cd boost_1_63_0
./bootstrap.sh
./b2
./b2 install

使用示例

從 HTTP GET 響應提取 JSON 數據

// Retrieves a JSON value from an HTTP request.
pplx::task<void> RequestJSONValueAsync()
{
    // TODO: To successfully use this example, you must perform the request  
    // against a server that provides JSON data.  
    // This example fails because the returned Content-Type is text/html and not application/json.
    http_client client(L"https:斜杠abc.def.com");
    return client.request(methods::GET).then([](http_response response) -> pplx::task<json::value>
    {
        if(response.status_code() == status_codes::OK)
        {
            return response.extract_json();
        }

        // Handle error cases, for now return empty json value... 
        return pplx::task_from_result(json::value());
    })
        .then([](pplx::task<json::value> previousTask)
    {
        try
        {
            const json::value& v = previousTask.get();
            // Perform actions here to process the JSON value...
        }
        catch (const http_exception& e)
        {
            // Print error.
            wostringstream ss;
            ss << e.what() << endl;
            wcout << ss.str();
        }
    });

    /* Output:
    Content-Type must be application/json to extract (is: text/html)
    */
}
0條評論
作者已關閉評論
a****k
16文章數
0粉絲數
a****k
16 文章 | 0 粉絲
原創

cpprestsdk編譯安裝使用

2024-04-30 09:17:41
102
0

CPP REST SDK是微軟開源的基于PPL的異步http client,網絡層使用的是Boost.Asio,跨平臺,并且支持json解析,在使用CPP REST SDK之前要確保已經安裝了boost和openssl

安裝boost和openssl

yum install boost-devel -y
yum install openssl-devel -y

安裝cpprestsdk

git clone https:斜杠github.com/microsoft/cpprestsdk
cd cpprestsdk
git submodule update --init
mkdir build && cd build
cmake ..
make -j4
make install

報錯:

cpprestsdk/Release/tests/functional/http/listener/listener_construction_tests.cpp:529:17: error: ‘class boost::asio::ssl::context’ has no member named ‘use_certificate_chain’; did you mean ‘use_certificate_file’?

原因:yum安裝boost只有1.53版本,要手動安裝1.63.0版本

解決:手動安裝boost

源碼下載:https:斜杠boostorg.jfrog.io/artifactory/main/release/
cd boost_1_63_0
./bootstrap.sh
./b2
./b2 install

使用示例

從 HTTP GET 響應提取 JSON 數據

// Retrieves a JSON value from an HTTP request.
pplx::task<void> RequestJSONValueAsync()
{
    // TODO: To successfully use this example, you must perform the request  
    // against a server that provides JSON data.  
    // This example fails because the returned Content-Type is text/html and not application/json.
    http_client client(L"https:斜杠abc.def.com");
    return client.request(methods::GET).then([](http_response response) -> pplx::task<json::value>
    {
        if(response.status_code() == status_codes::OK)
        {
            return response.extract_json();
        }

        // Handle error cases, for now return empty json value... 
        return pplx::task_from_result(json::value());
    })
        .then([](pplx::task<json::value> previousTask)
    {
        try
        {
            const json::value& v = previousTask.get();
            // Perform actions here to process the JSON value...
        }
        catch (const http_exception& e)
        {
            // Print error.
            wostringstream ss;
            ss << e.what() << endl;
            wcout << ss.str();
        }
    });

    /* Output:
    Content-Type must be application/json to extract (is: text/html)
    */
}
文章來自個人專欄
文章 | 訂閱
0條評論
作者已關閉評論
作者已關閉評論
0
0