github.com/gogf/gf/v2@v2.7.4/net/gclient/gclient_tracer_noop.go (about) 1 // Copyright GoFrame Author(https://goframe.org). All Rights Reserved. 2 // 3 // This Source Code Form is subject to the terms of the MIT License. 4 // If a copy of the MIT was not distributed with this file, 5 // You can obtain one at https://github.com/gogf/gf. 6 7 package gclient 8 9 import ( 10 "crypto/tls" 11 "net/http/httptrace" 12 "net/textproto" 13 ) 14 15 type clientTracerNoop struct{} 16 17 // newClientTracerNoop creates and returns object of httptrace.ClientTrace. 18 func newClientTracerNoop() *httptrace.ClientTrace { 19 c := &clientTracerNoop{} 20 return &httptrace.ClientTrace{ 21 GetConn: c.GetConn, 22 GotConn: c.GotConn, 23 PutIdleConn: c.PutIdleConn, 24 GotFirstResponseByte: c.GotFirstResponseByte, 25 Got100Continue: c.Got100Continue, 26 Got1xxResponse: c.Got1xxResponse, 27 DNSStart: c.DNSStart, 28 DNSDone: c.DNSDone, 29 ConnectStart: c.ConnectStart, 30 ConnectDone: c.ConnectDone, 31 TLSHandshakeStart: c.TLSHandshakeStart, 32 TLSHandshakeDone: c.TLSHandshakeDone, 33 WroteHeaderField: c.WroteHeaderField, 34 WroteHeaders: c.WroteHeaders, 35 Wait100Continue: c.Wait100Continue, 36 WroteRequest: c.WroteRequest, 37 } 38 } 39 40 // GetConn is called before a connection is created or 41 // retrieved from an idle pool. The hostPort is the 42 // "host:port" of the target or proxy. GetConn is called even 43 // if there's already an idle cached connection available. 44 func (*clientTracerNoop) GetConn(hostPort string) {} 45 46 // GotConn is called after a successful connection is 47 // obtained. There is no hook for failure to obtain a 48 // connection; instead, use the error from 49 // Transport.RoundTrip. 50 func (*clientTracerNoop) GotConn(httptrace.GotConnInfo) {} 51 52 // PutIdleConn is called when the connection is returned to 53 // the idle pool. If err is nil, the connection was 54 // successfully returned to the idle pool. If err is non-nil, 55 // it describes why not. PutIdleConn is not called if 56 // connection reuse is disabled via Transport.DisableKeepAlives. 57 // PutIdleConn is called before the caller's Response.Body.Close 58 // call returns. 59 // For HTTP/2, this hook is not currently used. 60 func (*clientTracerNoop) PutIdleConn(err error) {} 61 62 // GotFirstResponseByte is called when the first byte of the response 63 // headers is available. 64 func (*clientTracerNoop) GotFirstResponseByte() {} 65 66 // Got100Continue is called if the server replies with a "100 67 // Continue" response. 68 func (*clientTracerNoop) Got100Continue() {} 69 70 // Got1xxResponse is called for each 1xx informational response header 71 // returned before the final non-1xx response. Got1xxResponse is called 72 // for "100 Continue" responses, even if Got100Continue is also defined. 73 // If it returns an error, the client request is aborted with that error value. 74 func (*clientTracerNoop) Got1xxResponse(code int, header textproto.MIMEHeader) error { 75 return nil 76 } 77 78 // DNSStart is called when a DNS lookup begins. 79 func (*clientTracerNoop) DNSStart(httptrace.DNSStartInfo) {} 80 81 // DNSDone is called when a DNS lookup ends. 82 func (*clientTracerNoop) DNSDone(httptrace.DNSDoneInfo) {} 83 84 // ConnectStart is called when a new connection's Dial begins. 85 // If net.Dialer.DualStack (IPv6 "Happy Eyeballs") support is 86 // enabled, this may be called multiple times. 87 func (*clientTracerNoop) ConnectStart(network, addr string) {} 88 89 // ConnectDone is called when a new connection's Dial 90 // completes. The provided err indicates whether the 91 // connection completed successfully. 92 // If net.Dialer.DualStack ("Happy Eyeballs") support is 93 // enabled, this may be called multiple times. 94 func (*clientTracerNoop) ConnectDone(network, addr string, err error) {} 95 96 // TLSHandshakeStart is called when the TLS handshake is started. When 97 // connecting to an HTTPS site via an HTTP proxy, the handshake happens 98 // after the CONNECT request is processed by the proxy. 99 func (*clientTracerNoop) TLSHandshakeStart() {} 100 101 // TLSHandshakeDone is called after the TLS handshake with either the 102 // successful handshake's connection state, or a non-nil error on handshake 103 // failure. 104 func (*clientTracerNoop) TLSHandshakeDone(tls.ConnectionState, error) {} 105 106 // WroteHeaderField is called after the Transport has written 107 // each request header. At the time of this call the values 108 // might be buffered and not yet written to the network. 109 func (*clientTracerNoop) WroteHeaderField(key string, value []string) {} 110 111 // WroteHeaders is called after the Transport has written 112 // all request headers. 113 func (*clientTracerNoop) WroteHeaders() {} 114 115 // Wait100Continue is called if the Request specified 116 // "Expect: 100-continue" and the Transport has written the 117 // request headers but is waiting for "100 Continue" from the 118 // server before writing the request body. 119 func (*clientTracerNoop) Wait100Continue() {} 120 121 // WroteRequest is called with the result of writing the 122 // request and any body. It may be called multiple times 123 // in the case of retried requests. 124 func (*clientTracerNoop) WroteRequest(httptrace.WroteRequestInfo) {}