introduce a http3.RoundTripOpt to prevent closing of request stream (#3411)

This commit is contained in:
Marten Seemann 2022-05-20 11:54:31 +02:00 committed by GitHub
parent 6511723c28
commit de5f08171b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 107 additions and 73 deletions

View file

@ -38,7 +38,7 @@ func newRequestWriter(logger utils.Logger) *requestWriter {
}
}
func (w *requestWriter) WriteRequest(str quic.Stream, req *http.Request, gzip bool) error {
func (w *requestWriter) WriteRequest(str quic.Stream, req *http.Request, dontCloseStr, gzip bool) error {
buf := &bytes.Buffer{}
if err := w.writeHeaders(buf, req, gzip); err != nil {
return err
@ -48,7 +48,9 @@ func (w *requestWriter) WriteRequest(str quic.Stream, req *http.Request, gzip bo
}
// TODO: add support for trailers
if req.Body == nil {
str.Close()
if !dontCloseStr {
str.Close()
}
return nil
}
@ -84,7 +86,9 @@ func (w *requestWriter) WriteRequest(str quic.Stream, req *http.Request, gzip bo
return
}
}
str.Close()
if !dontCloseStr {
str.Close()
}
}()
return nil