Skip to content

Commit

Permalink
Check EnableFullDuplex err
Browse files Browse the repository at this point in the history
  • Loading branch information
francislavoie committed Aug 9, 2023
1 parent 490c764 commit 484b8ab
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion modules/caddyhttp/duplex_go120.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"net/http"
)

func enableFullDuplex(w http.ResponseWriter) {
func enableFullDuplex(w http.ResponseWriter) error {
// Do nothing, Go 1.20 and earlier do not support full duplex
return nil
}
4 changes: 2 additions & 2 deletions modules/caddyhttp/duplex_go121.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ import (
"net/http"
)

func enableFullDuplex(w http.ResponseWriter) {
http.NewResponseController(w).EnableFullDuplex()
func enableFullDuplex(w http.ResponseWriter) error {
return http.NewResponseController(w).EnableFullDuplex()

Check failure on line 24 in modules/caddyhttp/duplex_go121.go

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

response body must be closed (bodyclose)
}
5 changes: 4 additions & 1 deletion modules/caddyhttp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,10 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if s.EnableFullDuplex {
// TODO: Remove duplex_go12*.go abstraction once our
// minimum Go version is 1.21 or later
enableFullDuplex(w)
err := enableFullDuplex(w)
if err != nil {
s.accessLogger.Warn("failed to enable full duplex", zap.Error(err))
}
}

// encode the request for logging purposes before
Expand Down

0 comments on commit 484b8ab

Please sign in to comment.