cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: [PATCH] A CURLINFO_XFER_STATE perhaps?

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 6 Aug 2013 23:11:19 +0200 (CEST)

On Tue, 6 Aug 2013, Dan Fandrich wrote:

> SSL can take a number of round trips, especially with some of the exotic
> authentication methods possible, and over a high-latency connection it could
> take noticeable time. Another state I'd like to see made available is an
> authentication state, which is another one that can take several round trips
> for some protocols.

Right. But authentication is perhaps more like a property of the transfer
rather than a trancient state like the current set. I'm not seeing exactly how
I can fit auth in here. Any suggestion?

> Some of the state should probably also be available in proxy and non-proxy
> versions.

Right, that might be useful.

In the current patch, the CURLXFER_PROXYCONNECT state actually includes the
time the HTTP proxy will take to connect to the remote host and respond (in
the case of HTTP CONNECT). In all other cases, the states will be the with or
without a proxy as libcurl will simply resolve and connect to the proxy
instead of a remote host.

I could think of a set of proxy-states that would just add a bit to the host
version. Like having CURLXFER_CONNECT be for host and CURLXFER_CONNECT_PROXY
be the same state when using a proxy. Is there really a point in providing a
different set when using a proxy?

----
Without considering the code for the moment, let's play with a modified 
imaginary setup (adopting some of Rich's ideas too):
   #define CURLXFER_INIT         0x00 /* nothing really happened yet */
   #define CURLXFER_NAMERES      0x10 /* name resolving */
   #define CURLXFER_CONNECT      0x20 /* TCP (or similar) connect */
   #define CURLXFER_SECCONNECT   0x24 /* SSL/SSH crypto-oriented handshake */
   #define CURLXFER_PROTOCONNECT 0x28 /* protocol specific connect */
   #define CURLXFER_PROXYCONNECT 0x2c /* proxy CONNECT procedure */
   #define CURLXFER_WAITDO       0x30 /* waiting to issue request */
   #define CURLXFER_DO           0x34 /* issuing request */
   #define CURLXFER_TRANSFER     0x40 /* transfer */
   #define CURLXFER_TOOFAST      0x44 /* toggled transfer due to rate limiting,
                                         basically a variation of *TRANSFER */
   #define CURLXFER_DONE         0xf0 /* transfer complete */
This allows for some grouping like:
   #define CURLXFER_RANGE_INIT(x)    (!((x)&0xf0))
   #define CURLXFER_RANGE_NAME(x)    ((x)&0x10)
   #define CURLXFER_RANGE_CONNECT(x) ((x)&0x20)
   #define CURLXFER_RANGE_DO(x)      ((x)&0x30)
   #define CURLXFER_RANGE_XFER(x)    ((x)&0x40)
   #define CURLXFER_RANGE_DONE(x)    ((x)&0xf0)
... and there's actually room for adding new states inbetween somewhere in a 
future, if we'd ever come to that!
It would be very useful to get opinions on this from someone who actually has 
an application or other ideas of how to use this in a real world application!
-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2013-08-06