Don't corrupt response stream on GET_Value errors - #449
Open
mattjala wants to merge 1 commit into
Open
Conversation
GET_Value calls resp.prepare() before fetching any data, so a 200 and the
transfer-encoding headers are already on the wire by the time
getSelectionData() runs. So even if the outer handler ends up with e.g.
an internal server error, that status line just gets written into the body.
This can result in odd errors like:
`InvalidChunkLength(got length b'HTTP/1.1 500 Internal Server Error\r\n')`
which hides the underlying problem.
The paginated path in the same handler, and POST_Value, already work around this.
We just need to do the same thing in GET_Value.
Both handlers also reported the traceback via print(), so it went to stdout
instead of the log file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GET_Value calls resp.prepare() before fetching any data, so a 200 and the transfer-encoding headers are already on the wire by the time getSelectionData() runs. So even if the outer handler ends up with e.g. an internal server error, that status line just gets written into the body.
This can result in odd errors like:
InvalidChunkLength(got length b'HTTP/1.1 500 Internal Server Error\r\n')which hides the underlying problem.
The paginated path in the same handler, and POST_Value, already work around this. We just need to do the same thing in GET_Value.
Both handlers also reported the traceback via print(), so it went to stdout instead of the log file.