Closed postmodern closed 11 years ago
I have the same issue while trying to get
some url with mechanize.
Mechanize 2.5.1
Net-Http-Persistent 2.8
Ruby 2.0.0-dev (today's tree)
Do you have a simple, easy to reproduce example?
Using mechanize 2.5.1 and net-http-persistent 2.8 on ruby 2.0.0-rc2:
require 'mechanize'
agent = Mechanize.new
p agent.get('http://example.com/')
/home/hal/.gem/ruby/2.0.0/gems/net-http-persistent-2.8/lib/net/http/persistent.rb:959:in `rescue in request': too many connection resets (due to Content-Length (606) does not match response body length (1111) - EOFError) after 0 requests on 70321166174580, last used 1360376030.637872 seconds ago (Net::HTTP::Persistent::Error)
from /home/hal/.gem/ruby/2.0.0/gems/net-http-persistent-2.8/lib/net/http/persistent.rb:968:in `request'
from /home/hal/.gem/ruby/2.0.0/gems/mechanize-2.5.1/lib/mechanize/http/agent.rb:258:in `fetch'
from /home/hal/.gem/ruby/2.0.0/gems/mechanize-2.5.1/lib/mechanize/http/agent.rb:949:in `response_redirect'
from /home/hal/.gem/ruby/2.0.0/gems/mechanize-2.5.1/lib/mechanize/http/agent.rb:299:in `fetch'
from /home/hal/.gem/ruby/2.0.0/gems/mechanize-2.5.1/lib/mechanize/http/agent.rb:949:in `response_redirect'
from /home/hal/.gem/ruby/2.0.0/gems/mechanize-2.5.1/lib/mechanize/http/agent.rb:299:in `fetch'
from /home/hal/.gem/ruby/2.0.0/gems/mechanize-2.5.1/lib/mechanize.rb:407:in `get'
from mechanize_test.rb:6:in `block in <main>'
from mechanize_test.rb:5:in `times'
from mechanize_test.rb:5:in `<main>'
Actually the 100.times
isn't even necessary, fails on the first call.
This error is due to Ruby 2 handling content-encoding automatically under the covers, but not informing the user. The bug is actually in mechanize, but I'll leave this open.
Filed https://bugs.ruby-lang.org/issues/7831 with a patch, closing this.
Thank you!
While running the specs for gscraper I got the following error repeatedly under Ruby 2.0.0-preview1: