-
Notifications
You must be signed in to change notification settings - Fork 62
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
base: master
Are you sure you want to change the base?
Conversation
…ead of only returning the first 8192 bytes in the filewrapper buffer.
@@ -98,7 +103,7 @@ def __call__(self, event, context): | |||
|
|||
response = LambdaResponse() | |||
|
|||
body = next(self.wsgi_app( | |||
body = b''.join(self.wsgi_app( |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
When clicking the test button in api gateway

I get an error

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

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.