forked from quic-go/quic-go
http3: expose an OpenStream method on the RoundTripper (#4409)
The stream exposes two methods required for doing an HTTP request: SendRequestHeader and ReadResponse. This can be used by applications that wish to use the stream for non-HTTP content afterwards. This will lead to a simplification in the API we need to expose for WebTransport, and will make it easier to send HTTP Datagrams associated with this stream.
This commit is contained in:
@@ -431,11 +431,13 @@ var _ = Describe("HTTP tests", func() {
|
||||
|
||||
req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("https://localhost:%d/httpstreamer", port), nil)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
rsp, err := client.Transport.(*http3.RoundTripper).RoundTripOpt(req, http3.RoundTripOpt{DontCloseRequestStream: true})
|
||||
str, err := client.Transport.(*http3.RoundTripper).OpenStream(context.Background(), req.URL)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(str.SendRequestHeader(req)).To(Succeed())
|
||||
rsp, err := str.ReadResponse()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(rsp.StatusCode).To(Equal(200))
|
||||
|
||||
str := rsp.Body.(http3.HTTPStreamer).HTTPStream()
|
||||
b := make([]byte, 6)
|
||||
_, err = io.ReadFull(str, b)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
Reference in New Issue
Block a user