forked from quic-go/quic-go
http3: discard body from responses to HEAD requests (#4115)
* http3: HEAD method should not have a body * add tests * Update http3/server.go Co-authored-by: Marten Seemann <martenseemann@gmail.com> * ruduce the size of responseWriter --------- Co-authored-by: Marten Seemann <martenseemann@gmail.com>
This commit is contained in:
@@ -67,9 +67,10 @@ type responseWriter struct {
|
||||
bufferedStr *bufio.Writer
|
||||
buf []byte
|
||||
|
||||
headerWritten bool
|
||||
contentLen int64 // if handler set valid Content-Length header
|
||||
numWritten int64 // bytes written
|
||||
headerWritten bool
|
||||
isHead bool
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -162,6 +163,10 @@ func (w *responseWriter) Write(p []byte) (int, error) {
|
||||
return 0, http.ErrContentLength
|
||||
}
|
||||
|
||||
if w.isHead {
|
||||
return len(p), nil
|
||||
}
|
||||
|
||||
df := &dataFrame{Length: uint64(len(p))}
|
||||
w.buf = w.buf[:0]
|
||||
w.buf = df.Append(w.buf)
|
||||
|
||||
Reference in New Issue
Block a user