Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions v2/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ func (w *ResponseWriter) End() events.APIGatewayV2HTTPResponse {
w.out.Cookies = w.header["Set-Cookie"]
w.header.Del("Set-Cookie")

// ensure headers are written out
w.Write([]byte{})

// notify end
w.closeNotifyCh <- true

Expand Down
9 changes: 9 additions & 0 deletions v2/response_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,12 @@ func TestResponseWriter_WriteHeader(t *testing.T) {
assert.Equal(t, "Not Found\n", e.Body)
assert.Equal(t, "text/plain; charset=utf8", e.Headers["Content-Type"])
}

func TestResponseWriter_WriteHeadersWhenEmpty(t *testing.T) {
w := NewResponse()
w.Header().Set("Content-Type", "text/xml")

e := w.End()
assert.Equal(t, 200, e.StatusCode)
assert.Equal(t, "text/xml", e.Headers["Content-Type"])
}