Python event['Origin'] corresponds to event['origin'] on API Gateway
Description:
I use Python and access APIG's event['headers']['origin'] in the handler to manage CORS. I noticed that this corresponds to event['Origin'] (note the capital letter) in the sam-cli. Inconsistent?
Steps to reproduce the issue: Write a python handler with condition
if 'origin' in event['headers']:
...
and send a request with "Origin" header.
Observed result:
Condition is true using APIG and false using sam-cli.
Expected result:
Condition is true using both APIG and sam-cli.
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
Output of sam --version:
SAM CLI, version 0.3.0
Sorry in the title it should say event['headers']['origin'].
@poidl I am not seeing this behavior in APIGW. If you send a request with a "Origin" header, you will get "Origin" as the key in the event['headers'] object. APIGW passes this information through.
Headers are also case-insensitive, so you should be normalizing header keys in your code before comparison.
Closing as this is not a bug with SAM CLI.
Headers are also case-insensitive, so you should be normalizing header keys in your code before comparison.
Good to know. Thanks
On Mon, Jun 18, 2018, 23:19 Jacob Fuss [email protected] wrote:
Closed #479 https://github.com/awslabs/aws-sam-cli/issues/479.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/awslabs/aws-sam-cli/issues/479#event-1686154616, or mute the thread https://github.com/notifications/unsubscribe-auth/ABKQLHDg1Sw10lbsN-A7Dj2r0P0Zxp6aks5t96jqgaJpZM4UnYtc .