Rewind content at the end of Readable#to_s #21
Merged
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.
This allows calling
#read
after we've called#to_s
.This PR was motivated by httprb/http#437 (comment), where in httplog it was required to
#rewind
the form body after calling#to_s
on it (source). I just thought that this was surprising behaviour, and that there is no reason why not rewind the content after calling#to_s
on it.Btw, I think it makes sense to still keep the
#rewind
before the#read
, because httplog could one day decide they want to log the request data after the request has been made, at which point the form data objects would have been read. So then it would be nice to just be able to call#to_s
and have it rewind the content automatically.