Skip to content

Commit

Permalink
always reset header buffer, even when QPACK encoding fails (quic-go#3436
Browse files Browse the repository at this point in the history
)
  • Loading branch information
marten-seemann authored and sudarshan-reddy committed Aug 9, 2022
1 parent a4aeda6 commit 2232350
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions http3/request_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ func (w *requestWriter) writeHeaders(wr io.Writer, req *http.Request, gzip bool)
w.mutex.Lock()
defer w.mutex.Unlock()
defer w.encoder.Close()
defer w.headerBuf.Reset()

if err := w.encodeHeaders(req, gzip, "", actualContentLength(req)); err != nil {
return err
Expand All @@ -109,11 +110,8 @@ func (w *requestWriter) writeHeaders(wr io.Writer, req *http.Request, gzip bool)
if _, err := wr.Write(buf.Bytes()); err != nil {
return err
}
if _, err := wr.Write(w.headerBuf.Bytes()); err != nil {
return err
}
w.headerBuf.Reset()
return nil
_, err := wr.Write(w.headerBuf.Bytes())
return err
}

// copied from net/transport.go
Expand Down

0 comments on commit 2232350

Please sign in to comment.