Bug #6957
closedNet::HTTP#request_get bug
Description
Hello,
Looking at the source for Net::HTTP#request_get it says that if you pass in a block it will not read the body unless you call #read_body on the response. But when I pass in a block it seems that it reads the when the block exits, even though I did not call #read_body on the request. Consider this example:
url = "http://download.microsoft.com/download/1/6/5/165b076b-aaa9-443d-84f0-73cf11fdcdf8/WindowsXP-KB835935-SP2-ENU.exe"
uri = URI(url)
http = Net::HTTP.new(uri.hostname, uri.port)
http.request_get(uri.request_uri) do |req|
puts req["content-length"]
end # Program stops here for a long time - it must be downloading the body of the file?
compared to this:
http.request_get(uri.request_uri) do |req|
puts req["content-length"]
break # Now this method works as expected, it exits at this point without any delay
end