caddyhttp: Only attempt to enable full duplex for HTTP/1.x (#6102)

This commit is contained in:
Francis Lavoie 2024-02-13 13:45:38 -05:00 committed by GitHub
parent 30d63648f5
commit 2c48dda109
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

View File

@ -301,11 +301,11 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// enable full-duplex for HTTP/1, ensuring the entire
// request body gets consumed before writing the response
if s.EnableFullDuplex {
if s.EnableFullDuplex && r.ProtoMajor == 1 {
//nolint:bodyclose
err := http.NewResponseController(w).EnableFullDuplex()
if err != nil {
s.accessLogger.Warn("failed to enable full duplex", zap.Error(err))
s.logger.Warn("failed to enable full duplex", zap.Error(err))
}
}