Skip to content

Commit 5ba08e2

Browse files
author
Karel van IJperen
committed
Fix #164 runtime panic on incomplete/invalid URL
1 parent b08f231 commit 5ba08e2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

client.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func SendVia(req Request, svc Service) *ResponseFuture {
106106
// Send round-trips the request via the default Client. It does not block, instead returning a ResponseFuture
107107
// representing the asynchronous operation to produce the response. It is equivalent to:
108108
//
109-
// SendVia(req, Client)
109+
// SendVia(req, Client)
110110
func Send(req Request) *ResponseFuture {
111111
return SendVia(req, Client)
112112
}
@@ -123,10 +123,14 @@ func isH2C(ctx context.Context) bool {
123123
return b
124124
}
125125

126+
func isHTTP(r *http.Request) bool {
127+
return r.URL != nil && r.URL.Scheme == "http"
128+
}
129+
126130
type dynamicRoundTripper struct{}
127131

128132
func (d dynamicRoundTripper) RoundTrip(r *http.Request) (*http.Response, error) {
129-
if r.URL.Scheme == "http" && isH2C(r.Context()) {
133+
if isHTTP(r) && isH2C(r.Context()) {
130134
return H2cRoundTripper.RoundTrip(r)
131135
}
132136
return HTTPRoundTripper.RoundTrip(r)

0 commit comments

Comments
 (0)