Skip to content

Commit 8bf92b6

Browse files
committed
Revert handling of single value headers
1 parent 92e1f5d commit 8bf92b6

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

core/response.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,15 @@ func (r *ProxyResponseWriter) GetProxyResponse() (events.APIGatewayProxyResponse
103103
isBase64 = true
104104
}
105105

106+
proxyHeaders := make(map[string]string)
107+
108+
for h := range r.headers {
109+
proxyHeaders[h] = r.headers.Get(h)
110+
}
111+
106112
return events.APIGatewayProxyResponse{
107113
StatusCode: r.status,
114+
Headers: proxyHeaders,
108115
MultiValueHeaders: http.Header(r.headers),
109116
Body: output,
110117
IsBase64Encoded: isBase64,

core/response_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ var _ = Describe("ResponseWriter tests", func() {
154154
Expect(err).To(BeNil())
155155

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

170170
// Headers are not written to `Headers` field
171-
Expect(0).To(Equal(len(proxyResponse.Headers)))
171+
Expect(2).To(Equal(len(proxyResponse.Headers)))
172172

173173
// There are two headers here because Content-Type is always written implicitly
174174
Expect(2).To(Equal(len(proxyResponse.MultiValueHeaders["Set-Cookie"])))

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ require (
2828
github.com/json-iterator/go v0.0.0-20180128142709-bca911dae073
2929
github.com/kardianos/govendor v1.0.9 // indirect
3030
github.com/kataras/golog v0.0.0-20190624001437-99c81de45f40 // indirect
31-
github.com/kataras/iris v11.1.1+incompatible // indirect
31+
github.com/kataras/iris v11.1.1+incompatible
3232
github.com/kataras/pio v0.0.0-20190103105442-ea782b38602d // indirect
3333
github.com/klauspost/compress v1.7.4 // indirect
3434
github.com/klauspost/cpuid v1.2.1 // indirect

0 commit comments

Comments
 (0)