Project

General

Profile

Actions

Bug #3081

closed

lib/http wrong behavior for chunked reading

Added by marcandre (Marc-Andre Lafortune) almost 14 years ago. Updated almost 13 years ago.

Status:
Closed
Assignee:
-
Target version:
ruby -v:
ruby 1.9.2dev (2010-03-03 trunk 26805) [x86_64-darwin10.2.0]
Backport:
[ruby-core:29229]

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

Actions #1

Updated by mame (Yusuke Endoh) almost 14 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
This issue was solved with changeset r27605.
Marc-Andre, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

=end

Actions

Also available in: Atom PDF

Like0
Like0