cURL / Mailing Lists / curl-library / Single Mail


HTTP Connection events

From: Jonathan Masters <>
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

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,

      /* awaiting a completion of an asynch connect */
      data->result = Curl_is_connected(data->easy_conn,

//Added code
          msg = &data->msg;
          msg->extmsg.msg = CURLMSG_DONE;
          msg->extmsg.easy_handle = data;
          msg-> = CURLE_TCP_CONNECTED;

          result = multi_addmsg(multi, msg);

          multistate(data, CURLM_STATE_MSGSENT);

Is this useful to anyone else?

List admin:
Received on 2014-01-30