Skip to content

Commit

Permalink
Rewind IO-alike request body after it was consumed.
Browse files Browse the repository at this point in the history
Webmock triggers `body.each` twice upon inital request recording:

1. to perform request
2. to record request data into webmock request registry

But even without WebMock, generally Body#each must be replayable IMO.
  • Loading branch information
ixti committed Apr 24, 2018
1 parent 04f6878 commit 7939b70
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/http/request/body.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def each(&block)
yield @source
elsif @source.respond_to?(:read)
IO.copy_stream(@source, ProcIO.new(block))
@source.rewind if @source.respond_to?(:rewind)
elsif @source.is_a?(Enumerable)
@source.each(&block)
end
Expand Down

0 comments on commit 7939b70

Please sign in to comment.