(ctx context.Context, host string, h http.Header)
| 33 | } |
| 34 | |
| 35 | func newRequest(ctx context.Context, host string, h http.Header) *Request { |
| 36 | if requestID := api.RequestIDFromContext(ctx); requestID != "" { |
| 37 | h.Set(api.RequestIDHeader, requestID) |
| 38 | } |
| 39 | req := &Request{ |
| 40 | Header: h, |
| 41 | host: host, |
| 42 | } |
| 43 | // use trace to track timing |
| 44 | req.ctx = httptrace.WithClientTrace(ctx, &httptrace.ClientTrace{ |
| 45 | DNSStart: func(httptrace.DNSStartInfo) { req.dnsStartTime = time.Now() }, |
| 46 | GotConn: func(g httptrace.GotConnInfo) { req.gotConnInfo = g }, |
| 47 | GetConn: func(string) { req.getConnTime = time.Now() }, |
| 48 | GotFirstResponseByte: func() { req.firstByteTime = time.Now() }, |
| 49 | }) |
| 50 | return req |
| 51 | } |
| 52 | |
| 53 | func (r *Request) HTTPRequest() (*http.Request, error) { |
| 54 | body, err := r.getBody() |
no test coverage detected