-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Support for multiValueHeaders locally #830
Comments
I ran across this issue as well when using the Stackery layer so have worked on a quick fix. If you look at the DEVELOPER.md, pull my branch and use samdev it should work 😄 Tomorrow I will add tests and will make a proper PR in this repo 🎉 |
Given that #1190 was closed as a duplicate, I thought I should mention here that solving this issue may have become more urgent since #1154 was merged. As of that code merge, sending MultiValue headers results in 502 HTTP errors. The problem is that official aws golang libraries automatically send multivalue headers, specifically: aws-lambda-go-api-proxy: and various mentions of it here in https://github.com/aws/aws-lambda-go/blob/master/events/apigw.go |
#1166 was merged today and will go out in the next release. What that PR supported was the ability for you Lambda Function to return the #741 is handling the other side of multiValueHeaders. That is sending multiValueHeaders in the event to your function. Marking this as waiting-for-release. |
@jfuss both #1166 and #741 have merged, does that mean this issue is fixed? It looks like those changes were released? https://github.com/awslabs/aws-sam-cli/releases/tag/v0.17.0 Thank you. |
@btipling Please see my previous comment above |
This was released in v0.17.0 Closing. |
Description:
sam local start-api
doesn't detect or pass along any of themultiValueHeaders
from the lambda response.This is most notable (for me) because it defaults to
application/json
content type even though another header is sent, so for example HTML will be displayed as plain text in the browser.This is because it only checks the
headers
key in the lamba response, and not themultiValueHeaders
key.The code related to this issue is the
_parse_lambda_output
method, found here:https://github.com/awslabs/aws-sam-cli/blob/develop/samcli/local/apigw/local_apigw_service.py#L182-L214
Here's an example lambda response (using https://github.com/stackery/php-lambda-layer).
This works as expected once deployed, just not locally with
sam
.See also:
https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#api-gateway-simple-proxy-for-lambda-output-format
https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#apigateway-multivalue-headers-and-parameters
Steps to reproduce the issue:
template.yaml
like this:src/php/index.php
with any content, e.g.:sam local start-api
and go tohttp://127.0.0.1:3000/test
(or whatever the address).Observed result:
None of the headers are sent to the browser. Content is displayed as plain text.
The response headers are:
Expected result:
sam local start-api
detects theContent-Type
header from themultiValueHeaders
and the correct content type and other headers are sent to the browser. Content in this example is displayed properly as HTML.Response headers similar to this, which is what I get from AWS once deployed:
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
Linux
Output of
sam --version
:SAM CLI, version 0.8.1
Optional Debug logs:
The text was updated successfully, but these errors were encountered: