3

応答を受け取るためにcurlppを使用しています。このcurlppサイトの例http://curlpp.org/index.php/examples/64-example-14を参照しています。しかし、応答が保存されている場所がわからないため、さらに目的に使用できます。コードは、リクエストのステータスの整数値のみを示しています。私もグーグルを通過しましたが、それを理解することができません。

curlpp::Multi::Msgs msgs = requests.info();

for (curlpp::Multi::Msgs::iterator pos = msgs.begin(); pos != msgs.end(); pos++) 
{
    if (pos->second.msg == CURLMSG_DONE)
    {
        /* Find out which handle this message is about */
        if (pos->first == &request1)
        {
            printf("First request completed with status %d\n", pos->second.code);
        }
        else if (pos->first == &request2) 
        {
            printf("Second request completed with status %d\n", pos->second.code);
        }
    }
4

2 に答える 2

6

オプション WriteStream で他のストリームを指定できます。

std::stringstream result;

request.setOpt(cURLpp::Options::WriteStream(&result));
request.perform();
于 2012-06-23T21:39:46.307 に答える
1

前の例を読んでください。デフォルトでは、実行すると言うと、stdout に移動するか、他のストリームを指定できます。

同じサイトから、別の例http://curlpp.org/index.php/examples/48-example-01

myRequest.perform();
os << myRequest;

os はカスタム出力ストリームです

したがって、この例のような 2 つのストリームの場合は、次のようなものを追加します

os1 << request1;
os2 << request2;

両方の応答を取得するには

于 2011-06-19T07:25:29.573 に答える