Do multiple reads for WSGI even with content length #37
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.
For
.read()methodshttps://docs.python.org/3/library/io.html#io.RawIOBase.read
In practice, all WSGI servers seem to buffer the request to content-length before calling the app...except for pyvoy ;) Incidentally that means pyvoy is able to pass bidi streaming tests with WSGI too. I'm currently debugging an occasional macOS crash which seems envoy-related, but am feeling pretty good about the project.
I also took care to follow the WSGI spec "The application should not attempt to read more data than is specified by the CONTENT_LENGTH variable.". If this text wasn't there, it would be easiest to just call
.read()with no parameter.https://peps.python.org/pep-3333/#input-and-error-streams
I'm interested in adding pyvoy to conformance tests after some more debugging, but without it it's quite challenging to add a regression test for this change. I wanted to separate out the logic change from any testing changes but let me know if I should hold off until having that regression test.