开发者

to get response using curlpp

开发者 https://www.devze.com 2023-03-14 02:55 出处:网络
I am using curlpp to receive the response. I am referring this example of curlpp site http://curlpp.org/index.php/examples/64-example-14.

I am using curlpp to receive the response. I am referring this example of curlpp site http://curlpp.org/index.php/examples/64-example-14. But I am not getting where the response is stored so that I can use it for further purpose. The code is only showing the integer values of status of the request. I have gone through google also but not able to figure it out.

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 t开发者_如何学编程his 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);
        }
    }


You can specify other streams with the option WriteStream:

std::stringstream result;

request.setOpt(cURLpp::Options::WriteStream(&result));
request.perform();


Read the previous examples, by default when you say perform it goes to the stdout or you can specify other streams.

From the same site, different example http://curlpp.org/index.php/examples/48-example-01

myRequest.perform();
os << myRequest;

Where os is a custom output stream

so for two streams like this example add something like

os1 << request1;
os2 << request2;

to get both the responses

0

精彩评论

暂无评论...
验证码 换一张
取 消