rajbir
rajbir

Reputation: 39

to get response using curlpp

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 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);
        }
    }

Upvotes: 3

Views: 5684

Answers (2)

cheshir
cheshir

Reputation: 71

You can specify other streams with the option WriteStream:

std::stringstream result;

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

Upvotes: 6

Adithya Surampudi
Adithya Surampudi

Reputation: 4454

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

Upvotes: 1

Related Questions