From: Marc-Andre Lafortune Date: 2010-04-03T02:25:11+09:00 Subject: [ruby-core:29229] [Bug #3081] lib/http wrong behavior for chunked reading Bug #3081: lib/http wrong behavior for chunked reading http://redmine.ruby-lang.org/issues/show/3081 Author: Marc-Andre Lafortune Status: Open, Priority: Normal Category: lib, Target version: 1.9.2 ruby -v: ruby 1.9.2dev (2010-03-03 trunk 26805) [x86_64-darwin10.2.0] 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 ---------------------------------------- http://redmine.ruby-lang.org