Skip to content

Commit a0b7b0a

Browse files
authored
To avoid duplicate response headers, only populate MultiValueHeaders (awslabs#73)
1 parent f66f79a commit a0b7b0a

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

core/response.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,8 @@ 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-
112106
return events.APIGatewayProxyResponse{
113107
StatusCode: r.status,
114-
Headers: proxyHeaders,
115108
MultiValueHeaders: http.Header(r.headers),
116109
Body: output,
117110
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 also written to `Headers` field
157-
Expect(1).To(Equal(len(proxyResponse.Headers)))
156+
// Headers are not also written to `Headers` field
157+
Expect(0).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 also written to `Headers` field
171-
Expect(2).To(Equal(len(proxyResponse.Headers)))
170+
// Headers are not also written to `Headers` field
171+
Expect(0).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"])))

0 commit comments

Comments
 (0)