chore(deps): bump golang from 1.16.6 to 1.17.0 in /.github/go (#185)
* chore(deps): bump golang from 1.16.6 to 1.17.0 in /.github/go Bumps golang from 1.16.6 to 1.17.0. --- updated-dependencies: - dependency-name: golang dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * fix: guard against writing HTTP Status 0 Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
This commit is contained in:
@@ -1 +1 @@
|
||||
FROM golang:1.16.6
|
||||
FROM golang:1.17.0
|
||||
|
||||
@@ -224,7 +224,9 @@ func setResponseCookies(w http.ResponseWriter, r *http.Request, h *model.Handler
|
||||
func setResponseBody(w http.ResponseWriter, r *http.Request, h *model.Handler) {
|
||||
|
||||
if !h.BodyOut {
|
||||
h.Writer.WriteHeader(h.Status)
|
||||
if h.Status != 0 {
|
||||
h.Writer.WriteHeader(h.Status)
|
||||
}
|
||||
h.BodyOut = true
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ import (
|
||||
func TestErrorJSONSetsAppJsonContentType(t *testing.T) {
|
||||
w := httptest.NewRecorder()
|
||||
|
||||
httperror.ErrorJSON(w, "Not Important Here", 0)
|
||||
httperror.ErrorJSON(w, "Not Important Here", 500)
|
||||
|
||||
if v := w.Result().Header.Get("Content-Type"); v != "application/json; charset=utf-8" {
|
||||
t.Errorf("Content-Type header mismatch. Expected: %q, got: %q", "application/json; charset=utf-8", v)
|
||||
|
||||
@@ -51,3 +51,5 @@ type Handler struct {
|
||||
// The transfer of the body has started
|
||||
BodyOut bool
|
||||
}
|
||||
|
||||
// TODO: add a Handler smart constructor to initialize Status to 200
|
||||
|
||||
@@ -77,7 +77,9 @@ func handlerBuilder(route model.Route) http.Handler {
|
||||
|
||||
// In case of the user not setting /request/body
|
||||
if !h.BodyOut {
|
||||
h.Writer.WriteHeader(h.Status)
|
||||
if h.Status != 0 {
|
||||
h.Writer.WriteHeader(h.Status)
|
||||
}
|
||||
h.BodyOut = true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user