Bug #3081
closedlib/http wrong behavior for chunked reading
Description
=begin
Take the following code:
require 'net/http'
uri = URI.parse("http://banners.wunderground.com/banner/krd_condV2/language/www/US/FL/Miami.gif")
http = Net::HTTP.new(uri.host, uri.port)
http.request_get(uri.request_uri) do |res|
res.read_body do |chunk|
puts "read #{chunk.size} bytes"
break
end
puts "Done"
end
puts "Bye"
in Ruby 1.8.7 or in 1.9.2dev, it outputs the following:
read 1024 bytes
Done
/usr/local/rubydev/lib/ruby/1.9.1/net/http.rb:2433:in read_chunked': wrong chunk size line: (Net::HTTPBadResponse) from /usr/local/rubydev/lib/ruby/1.9.1/net/http.rb:2411:in
read_body_0'
from /usr/local/rubydev/lib/ruby/1.9.1/net/http.rb:2371:in read_body' from /usr/local/rubydev/lib/ruby/1.9.1/net/http.rb:2396:in
body'
from /usr/local/rubydev/lib/ruby/1.9.1/net/http.rb:2335:in reading_body' from /usr/local/rubydev/lib/ruby/1.9.1/net/http.rb:1185:in
transport_request'
from /usr/local/rubydev/lib/ruby/1.9.1/net/http.rb:1169:in request' from /usr/local/rubydev/lib/ruby/1.9.1/net/http.rb:1162:in
block in request'
from /usr/local/rubydev/lib/ruby/1.9.1/net/http.rb:627:in start' from /usr/local/rubydev/lib/ruby/1.9.1/net/http.rb:1160:in
request'
from /usr/local/rubydev/lib/ruby/1.9.1/net/http.rb:1073:in request_get' from b.rb:5:in
'
There's apparently nothing wrong with the server; remove the 'break' statement and you get instead:
read 1024 bytes
read 597 bytes
read 2 bytes
Done
Bye
=end