Keep request body in memory also after consuming request body #395
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.
The
Server
will always buffer the incoming request body (unless theStreamingRequestMiddleware
is used). Previously, this buffer would be cleared when the request body has been parsed successfully. This means that the request body was only present for some requests.This changeset ensures we keep the request body in memory also after consuming the request body. This means consumers can now always access the complete request body as detailed in the documentation. This allows building custom parsers and more advanced processing models without having to mess with the default parsers.
This shouldn't have a significant effect on memory consumption because the default buffer size is limited as per #371.
This also makes us less dependent on the underlying PSR-7 implementation which allows us to possibly change this in the future (#331).
Resolves #386, #387, #390 and others.