1 // Copyright 2018 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4 5 //go:build !js
6 7 package http
8 9 import _ "unsafe" // for linkname
10 11 // RoundTrip should be an internal detail,
12 // but widely used packages access it using linkname.
13 // Notable members of the hall of shame include:
14 // - github.com/erda-project/erda-infra
15 //
16 // Do not remove or change the type signature.
17 // See go.dev/issue/67401.
18 //
19 //go:linkname badRoundTrip net/http.(*Transport).RoundTrip
20 func badRoundTrip(*Transport, *Request) (*Response, error)
21 22 // RoundTrip implements the [RoundTripper] interface.
23 //
24 // For higher-level HTTP client support (such as handling of cookies
25 // and redirects), see [Get], [Post], and the [Client] type.
26 //
27 // Like the RoundTripper interface, the error types returned
28 // by RoundTrip are unspecified.
29 func (t *Transport) RoundTrip(req *Request) (*Response, error) {
30 if t == nil {
31 panic("transport is nil")
32 }
33 return t.roundTrip(req)
34 }
35