Skip to content
This repository was archived by the owner on May 21, 2025. It is now read-only.

Commit 8650bc2

Browse files
nsarychevsnabb
andauthored
Re-add handling of single value headers (#55)
* Revert handling of single value headers * Change test comments Co-authored-by: Janne Snabb <[email protected]>
1 parent 8214f34 commit 8650bc2

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ var _ = Describe("ResponseWriter tests", func() {
153153
proxyResponse, err := response.GetProxyResponse()
154154
Expect(err).To(BeNil())
155155

156-
// Headers are not written to `Headers` field
157-
Expect(0).To(Equal(len(proxyResponse.Headers)))
156+
// Headers are also written to `Headers` field
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
})
@@ -167,8 +167,8 @@ var _ = Describe("ResponseWriter tests", func() {
167167
proxyResponse, err := response.GetProxyResponse()
168168
Expect(err).To(BeNil())
169169

170-
// Headers are not written to `Headers` field
171-
Expect(0).To(Equal(len(proxyResponse.Headers)))
170+
// Headers are also written to `Headers` field
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)