Skip to content

Commit

Permalink
chore: fixed the out-of-order WriteHeader call
Browse files Browse the repository at this point in the history
  • Loading branch information
johnabass committed Aug 20, 2024
1 parent 9f4da81 commit d5ed9b5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion basculehttp/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,11 @@ func (m *Middleware) ThenFunc(protected http.HandlerFunc) http.Handler {
// writeRawError is a fallback to write an error that came from this package.
// The response is always a text/plain representation of the error.
func (m *Middleware) writeRawError(response http.ResponseWriter, err error) {
response.WriteHeader(http.StatusInternalServerError)
response.Header().Set("Content-Type", "text/plain; charset=utf-8")

errBody := []byte(err.Error())
response.Header().Set("Content-Length", strconv.Itoa(len(errBody)))
response.WriteHeader(http.StatusInternalServerError)
response.Write(errBody)
}

Expand Down

0 comments on commit d5ed9b5

Please sign in to comment.