Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove the SkipSchemeCheck RoundTripOpt #3353

Merged
merged 1 commit into from
Mar 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions http3/roundtrip.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strings"
"sync"

quic "github.com/lucas-clemente/quic-go"
"github.com/lucas-clemente/quic-go"

"golang.org/x/net/http/httpguts"
)
Expand Down Expand Up @@ -64,9 +64,6 @@ type RoundTripOpt struct {
// OnlyCachedConn controls whether the RoundTripper may create a new QUIC connection.
// If set true and no cached connection is available, RoundTrip will return ErrNoCachedConn.
OnlyCachedConn bool
// SkipSchemeCheck controls whether we check if the scheme is https.
// This allows the use of different schemes, e.g. masque://target.example.com:443/.
SkipSchemeCheck bool
}

var _ roundTripCloser = &RoundTripper{}
Expand Down Expand Up @@ -100,7 +97,7 @@ func (r *RoundTripper) RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.
}
}
}
} else if !opt.SkipSchemeCheck {
} else {
closeRequestBody(req)
return nil, fmt.Errorf("http3: unsupported protocol scheme: %s", req.URL.Scheme)
}
Expand Down
9 changes: 0 additions & 9 deletions http3/roundtrip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,6 @@ var _ = Describe("RoundTripper", func() {
Expect(req.Body.(*mockBody).closed).To(BeTrue())
})

It("allow non-https schemes if SkipSchemeCheck is set", func() {
req, err := http.NewRequest("GET", "masque://www.example.org/", nil)
Expect(err).ToNot(HaveOccurred())
_, err = rt.RoundTrip(req)
Expect(err).To(MatchError("http3: unsupported protocol scheme: masque"))
_, err = rt.RoundTripOpt(req, RoundTripOpt{SkipSchemeCheck: true, OnlyCachedConn: true})
Expect(err).To(MatchError("http3: no cached connection was available"))
})

It("rejects requests without a URL", func() {
req1.URL = nil
req1.Body = &mockBody{}
Expand Down