Skip to content

Revert handling of single value headers #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 4, 2020
Merged
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
7 changes: 7 additions & 0 deletions core/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,15 @@ func (r *ProxyResponseWriter) GetProxyResponse() (events.APIGatewayProxyResponse
isBase64 = true
}

proxyHeaders := make(map[string]string)

for h := range r.headers {
proxyHeaders[h] = r.headers.Get(h)
}

return events.APIGatewayProxyResponse{
StatusCode: r.status,
Headers: proxyHeaders,
MultiValueHeaders: http.Header(r.headers),
Body: output,
IsBase64Encoded: isBase64,
Expand Down
4 changes: 2 additions & 2 deletions core/response_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ var _ = Describe("ResponseWriter tests", func() {
Expect(err).To(BeNil())

// Headers are not written to `Headers` field
Expect(0).To(Equal(len(proxyResponse.Headers)))
Expect(1).To(Equal(len(proxyResponse.Headers)))
Expect(1).To(Equal(len(proxyResponse.MultiValueHeaders["Content-Type"])))
Expect("application/json").To(Equal(proxyResponse.MultiValueHeaders["Content-Type"][0]))
})
Expand All @@ -168,7 +168,7 @@ var _ = Describe("ResponseWriter tests", func() {
Expect(err).To(BeNil())

// Headers are not written to `Headers` field
Expect(0).To(Equal(len(proxyResponse.Headers)))
Expect(2).To(Equal(len(proxyResponse.Headers)))

// There are two headers here because Content-Type is always written implicitly
Expect(2).To(Equal(len(proxyResponse.MultiValueHeaders["Set-Cookie"])))
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ require (
github.com/json-iterator/go v0.0.0-20180128142709-bca911dae073
github.com/kardianos/govendor v1.0.9 // indirect
github.com/kataras/golog v0.0.0-20190624001437-99c81de45f40 // indirect
github.com/kataras/iris v11.1.1+incompatible // indirect
github.com/kataras/iris v11.1.1+incompatible
github.com/kataras/pio v0.0.0-20190103105442-ea782b38602d // indirect
github.com/klauspost/compress v1.7.4 // indirect
github.com/klauspost/cpuid v1.2.1 // indirect
Expand Down