SoupSessionAsync with ostream



Hello

I wanted to use Libsoup to download some files from Internet ... Asynchronously ,
can I get some help? and can you explain to me how callback function works?

here what I have tried

{
SoupSession *session;
    SoupMessage *msg;
    guint status;
   
    session = soup_session_async_new();
    msg = soup_message_new (SOUP_METHOD_GET, url);
      // send the HTTP request
    status = soup_session_send_message (session ,msg);

    soup_session_queue_message (session, msg, myCallback, &os);
}

static void myCallback (SoupSession *session, SoupMessage *msg , gpointer user_data)
{
                     
        Glib::RefPtr<ostream> os = st atic_cast<ostream*>(user_data);
      // output the(msg->response_body->data)
        streamsize len= (msg->response_body->length);
        os->write(msg->response_body->data , len);                                        

   
}


thanks


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]