fakeweb icon indicating copy to clipboard operation
fakeweb copied to clipboard

FakeWeb doesn't mimic Net::HTTP's check "#read_body called twice (IOError)"

Open chrisk opened this issue 12 years ago • 0 comments

This should raise Net::HTTPOK#read_body called twice (IOError) (or whatever the appropriate Net::HTTPResponse class is, there) whether or not the request hits FakeWeb:

%w(net/http rubygems fakeweb).each { |it| require it }
FakeWeb.register_uri(:get, "http://example.com", body: "example")
Net::HTTP.new("example.com").request_get("/") do |response|
  2.times { response.read_body { |part| p part } }
end

I found this with 1.9.3 p392; need to check the behavior of all the other implementations. I also see some other things in there we're probably not handling correctly, like #read_body's deprecated-but-still-working dest parameter—need to file issues for those.

chrisk avatar May 15 '13 10:05 chrisk