Skip to content

Commit cbb5f9d

Browse files
committed
fix(httpx): handle transports other than http.Transport
1 parent 790c8f9 commit cbb5f9d

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

httpx/client.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@ func NewClient() *http.Client {
2323
}
2424
}
2525

26-
func NewTransport() *http.Transport {
27-
transport := http.DefaultTransport.(*http.Transport).Clone()
26+
func NewTransport() http.RoundTripper {
27+
t, ok := http.DefaultTransport.(*http.Transport)
28+
if !ok {
29+
return http.DefaultTransport
30+
}
31+
transport := t.Clone()
2832
transport.DialContext = (&net.Dialer{
2933
Timeout: 20 * time.Second,
3034
}).DialContext

0 commit comments

Comments
 (0)