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

fix potential none reference and truncated response body when loading static files #10

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

snowbldr
Copy link

@snowbldr snowbldr commented Jan 4, 2021

When clicking the test button in api gateway
image

I get an error
image

I logged out the event as json and found that headers was null
image

This commit adds a guard for if the headers is null, in addition initializes a few keys in the environ to an empty string to prevent key errors.

I also experience and error where all of the responses were truncated to only the first 8192 bytes when sending a static file. This is because the wsgi_app returns and iterator with an 8192k buffer, so the iterator must be exhausted to get the entire body.

@snowbldr snowbldr changed the title fix potential none reference fix potential none reference and truncated response body when loading static files Jan 7, 2021
@@ -98,7 +103,7 @@ def __call__(self, event, context):

response = LambdaResponse()

body = next(self.wsgi_app(
body = b''.join(self.wsgi_app(

Choose a reason for hiding this comment

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

This change here fixed the issue we've been having for days.

204 response codes in Werkzeug break next as the iterator that's returned is wrong somehow. Doing this instead works just fine.

Copy link
Author

Choose a reason for hiding this comment

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

Awesome! Glad to hear it. This had me stumped for a while too.

Choose a reason for hiding this comment

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

Thanks for this! Fixed an issue I was having with OPTIONS requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants