davecheney / httpstat

It's like curl -v, with colours.
MIT License
7.07k stars 385 forks source link

Use httptrace GotConn instead of WroteHeaders #104

Closed moorereason closed 8 years ago

moorereason commented 8 years ago

After doing some additional testing, it appears that the GotConn hook fires after TLS has been established. TLS Handshake time is between ConnectDone and GotConn.

moorereason commented 8 years ago

I know it's dangerously close to release time, but I think this PR finally gets it right. Tested on linux-amd64 and windows-amd64.

Debug output from my iss90 branch:

$ ./http-gotconn -H "X-Factor: $BIG" https://requestb.in/19irncp1
. GetConn
. DNSStart 1.00682ms after GetConn
. DNSDone 15.979358ms after DNSStart
. ConnectStart 149.668µs after DNSDone

Connected to 104.31.86.204:443
. ConnectDone 14.033463ms after ConnectStart
. GotConn 149.985672ms after ConnectDone
. WroteHeaders: 840.739µs after GotConn
. . 150.825713ms after ConnectDone
. WroteRequest 1.126247ms after WroteHeaders
. GotFirstResponseByte 113.050125ms after WroteRequest

HTTP/2.0 200 OK
Server: cloudflare-nginx
Cf-Ray: 2eadeaf98e3858bb-DFW
Content-Type: text/html; charset=utf-8
Date: Sat, 01 Oct 2016 06:39:30 GMT
Set-Cookie: __cfduid=daab2a43aed262ac5cdac23e2f9e47cc51475303970; expires=Sun, 01-Oct-17 06:39:30 GMT; path=/; domain=.requestb.in; HttpOnly
Sponsored-By: https://www.runscope.com
Via: 1.1 vegur

Body discarded

  DNS Lookup   TCP Connection   TLS Handshake   Server Processing   Content Transfer
[     15ms  |          14ms  |        149ms  |            114ms  |             0ms  ]
            |                |               |                   |                  |
   namelookup:15ms           |               |                   |                  |
                       connect:30ms          |                   |                  |
                                   pretransfer:180ms             |                  |
                                                     starttransfer:294ms            |
                                                                                total:294ms