MCPcopy Create free account
hub / github.com/imroc/req / createContext

Method createContext

trace.go:125–164  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

123}
124
125func (t *clientTrace) createContext(ctx context.Context) context.Context {
126 return httptrace.WithClientTrace(
127 ctx,
128 &httptrace.ClientTrace{
129 DNSStart: func(_ httptrace.DNSStartInfo) {
130 t.dnsStart = time.Now()
131 },
132 DNSDone: func(_ httptrace.DNSDoneInfo) {
133 t.dnsDone = time.Now()
134 },
135 ConnectStart: func(_, _ string) {
136 if t.dnsDone.IsZero() {
137 t.dnsDone = time.Now()
138 }
139 if t.dnsStart.IsZero() {
140 t.dnsStart = t.dnsDone
141 }
142 },
143 ConnectDone: func(net, addr string, err error) {
144 t.connectDone = time.Now()
145 },
146 GetConn: func(_ string) {
147 t.getConn = time.Now()
148 },
149 GotConn: func(ci httptrace.GotConnInfo) {
150 t.gotConn = time.Now()
151 t.gotConnInfo = ci
152 },
153 GotFirstResponseByte: func() {
154 t.gotFirstResponseByte = time.Now()
155 },
156 TLSHandshakeStart: func() {
157 t.tlsHandshakeStart = time.Now()
158 },
159 TLSHandshakeDone: func(_ tls.ConnectionState, _ error) {
160 t.tlsHandshakeDone = time.Now()
161 },
162 },
163 )
164}

Callers 1

roundTripMethod · 0.80

Calls 1

IsZeroMethod · 0.80

Tested by

no test coverage detected