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

Feature request: Response should support multiValueHeaders #1450

Closed
2 tasks done
wayne-folkes opened this issue Aug 12, 2022 · 5 comments · Fixed by #1455
Closed
2 tasks done

Feature request: Response should support multiValueHeaders #1450

wayne-folkes opened this issue Aug 12, 2022 · 5 comments · Fixed by #1455
Assignees
Labels
breaking-change Breaking change feature-request feature request v2

Comments

@wayne-folkes
Copy link

Use case

I have a lambda function with an ALB event source, I was attempting to use Response (from aws_lambda_powertools.event_handler import content_types, Response) instead of constructing the response by hand

return Response(
    status_code=200,
    body=data,
    content_type=content_types.APPLICATION_JSON)

instead of

return {
   "statusCode": 200,
   "statusDescription": "200 OK",
   "multiValueHeaders": {
       "Content-Type":    ["application/json"]
        },
    "body": data
}

the ALB responds with a 502 when using Response I suspect it is because multiValueHeaders is not included in the response.
To get around this, I am doing the following but it is not elegant

response = Response(
  status_code=status_code,
  body=data,
  content_type=content_types.APPLICATION_JSON
        ).__dict__

response["multiValueHeaders"] = {
        "Content-Type": ["application/json"]
}

return response

Solution/User Experience

I would like for the Response object to be able to detect multiValueHeaders in the request and use that to determine if the response should do the same

Alternative solutions

An alternative could be to have MultiValueResponse object that works the same as Response but sends `multiValueHeaders`

Acknowledgment

@wayne-folkes wayne-folkes added feature-request feature request triage Pending triage from maintainers labels Aug 12, 2022
@boring-cyborg
Copy link

boring-cyborg bot commented Aug 12, 2022

Thanks for opening your first issue here! We'll come back to you as soon as we can.

@heitorlessa
Copy link
Contributor

@rubenfonseca when you can, could you share the update here as this was implemented for v2?

@heitorlessa
Copy link
Contributor

re-assigning @rubenfonseca for visibility as this is already done in V2 and ready to go by Friday or next week (in case we spot anything wrong in V2 final tests)

@heitorlessa heitorlessa added v2 and removed triage Pending triage from maintainers labels Oct 11, 2022
@heitorlessa
Copy link
Contributor

Closing as we're wrap to launch V2

@github-actions
Copy link
Contributor

⚠️COMMENT VISIBILITY WARNING⚠️

This issue is now closed. Please be mindful that future comments are hard for our team to see.

If you need more assistance, please either tag a team member or open a new issue that references this one.

If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Breaking change feature-request feature request v2
Projects
None yet
3 participants