cURL / Mailing Lists / curl-library / Single Mail

curl-library

HTTP Connection events

From: Jonathan Masters <jon_at_than.cc>
Date: Thu, 30 Jan 2014 11:26:10 +0000

I'm not sure if it is just my special cases but without using any
connect/disconnect callbacks, I don't see how you would know that a
HTTP connection was successful in the case of a chunked transfer.

For example.

1. Client GET HTTP.
2. HTTP server sends chunked messages. If this chunked message
terminates with a 0 chunk, then there is a curl message in
curl_multi_info_read. If this chunked message goes on forever, then
there is never a message created, the user doesn't know the connection
was successful.

This is the problem I was facing, the server I am connecting to sends
events, the connection is persistent and never dies. I technically
know the connection is successful when I start receiving data, but as
CURL knows this I thought it would be cleaner if curl created a
message.

As I've said before I'm no expert on CURL, but I've added the below
which seems to work so far in multi.c, just after,

case CURLM_STATE_WAITCONNECT:
      /* awaiting a completion of an asynch connect */
      data->result = Curl_is_connected(data->easy_conn,
                                       FIRSTSOCKET,
                                       &connected);

//Added code
//----------------------------------------------
 if(connected)
      {
          msg = &data->msg;
          msg->extmsg.msg = CURLMSG_DONE;
          msg->extmsg.easy_handle = data;
          msg->extmsg.data.result = CURLE_TCP_CONNECTED;

          result = multi_addmsg(multi, msg);

          multistate(data, CURLM_STATE_MSGSENT);
      }

Is this useful to anyone else?

Thanks
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-01-30