Skip to content
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

feat: support both enable/disable attribute for multi value headers on ALB #392

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
12 changes: 10 additions & 2 deletions src/event-sources/aws/alb.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,24 @@ const { getRequestValuesFromEvent, getMultiValueHeaders } = require('../utils')

const getRequestValuesFromAlbEvent = ({ event }) => getRequestValuesFromEvent({ event })
const getResponseToAlb = ({
event,
statusCode,
body,
headers,
headers: responseHeaders,
isBase64Encoded
}) => {
const multiValueHeaders = getMultiValueHeaders({ headers })
const multiValueHeaders = !event.headers ? getMultiValueHeaders({ headers: responseHeaders }) : undefined
const headers = event.headers
? Object.entries(responseHeaders).reduce((acc, [k, v]) => {
acc[k] = Array.isArray(v) ? v[0] : v
return acc
}, {})
: undefined
Comment on lines +11 to +17
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add some comments on what we're trying to do here? Why are we using event.headers (request headers) for response headers?


return {
statusCode,
body,
headers,
multiValueHeaders,
isBase64Encoded
}
Expand Down
3 changes: 3 additions & 0 deletions src/transport.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ function forwardResponse ({
response,
resolver,
eventSource,
event,
log
}) {
const statusCode = response.statusCode
Expand All @@ -30,6 +31,7 @@ function forwardResponse ({
})

const successResponse = eventSource.getResponse({
event,
statusCode,
body,
headers,
Expand Down Expand Up @@ -141,6 +143,7 @@ async function forwardRequestToNodeServer ({
response,
resolver,
eventSource,
event,
log
})
return response
Expand Down