lostisland / hurley

DEAD project, don't use
MIT License
177 stars 21 forks source link

Issue getting from http://github.com on JRuby #22

Closed jasonrclark closed 9 years ago

jasonrclark commented 9 years ago

Hey there! Ran the following steps to see whether hurley would allow me past a redirection limitation I was hitting with open-uri, but instead ran into this error:

[1] pry(main)> require 'hurley'
=> true
[2] pry(main)> Hurley.get("http://github.com")
TypeError: can't convert Net::ReadAdapter into String
from org/jruby/ext/stringio/StringIO.java:143:in `initialize'

Works fine if I run on MRI 2.1.5, but unfortunately my target app is JRuby-based.

JRuby version:

jruby 1.7.16.1 (1.9.3p392) 2014-10-28 4e93f31 on Java HotSpot(TM) 64-Bit Server VM 1.8.0_20-b26 [darwin-x86_64]
technoweenie commented 9 years ago

I'd need a better stacktrace to even begin to look at this.

jasonrclark commented 9 years ago

Following's the stack trace when I run this script (using a more recent JRuby 1.7).

Also tested it on JRuby 9k, and it works fine there for what that's worth.

~/source/shoes4:cat testing/hurley.rb
require 'hurley'
Hurley.get("http://github.com")

✔ ♥♥♥♥ [jruby-1.7.22] (master)*
~/source/shoes4:jruby testing/hurley.rb
TypeError: can't convert Net::ReadAdapter into String
           initialize at org/jruby/ext/stringio/StringIO.java:143
                  get at /Users/jclark/.rbenv/versions/jruby-1.7.22/lib/ruby/1.9/net/http.rb:1041
    transport_request at /Users/jclark/.rbenv/versions/jruby-1.7.22/lib/ruby/1.9/net/http.rb:1331
         reading_body at /Users/jclark/.rbenv/versions/jruby-1.7.22/lib/ruby/1.9/net/http.rb:2680
    transport_request at /Users/jclark/.rbenv/versions/jruby-1.7.22/lib/ruby/1.9/net/http.rb:1330
                catch at org/jruby/RubyKernel.java:1242
    transport_request at /Users/jclark/.rbenv/versions/jruby-1.7.22/lib/ruby/1.9/net/http.rb:1325
              request at /Users/jclark/.rbenv/versions/jruby-1.7.22/lib/ruby/1.9/net/http.rb:1302
              request at /Users/jclark/.rbenv/versions/jruby-1.7.22/lib/ruby/1.9/net/http.rb:1295
                start at /Users/jclark/.rbenv/versions/jruby-1.7.22/lib/ruby/1.9/net/http.rb:746
              request at /Users/jclark/.rbenv/versions/jruby-1.7.22/lib/ruby/1.9/net/http.rb:1293
                  get at /Users/jclark/.rbenv/versions/jruby-1.7.22/lib/ruby/1.9/net/http.rb:1035
      perform_request at /Users/jclark/.rbenv/versions/jruby-1.7.22/lib/ruby/gems/shared/gems/hurley-0.2/lib/hurley/connection.rb:80
                 call at /Users/jclark/.rbenv/versions/jruby-1.7.22/lib/ruby/gems/shared/gems/hurley-0.2/lib/hurley/connection.rb:15
           initialize at /Users/jclark/.rbenv/versions/jruby-1.7.22/lib/ruby/gems/shared/gems/hurley-0.2/lib/hurley/client.rb:252
                 call at /Users/jclark/.rbenv/versions/jruby-1.7.22/lib/ruby/gems/shared/gems/hurley-0.2/lib/hurley/connection.rb:14
  net_http_connection at /Users/jclark/.rbenv/versions/jruby-1.7.22/lib/ruby/gems/shared/gems/hurley-0.2/lib/hurley/connection.rb:58
                 call at /Users/jclark/.rbenv/versions/jruby-1.7.22/lib/ruby/gems/shared/gems/hurley-0.2/lib/hurley/connection.rb:12
  call_with_redirects at /Users/jclark/.rbenv/versions/jruby-1.7.22/lib/ruby/gems/shared/gems/hurley-0.2/lib/hurley/client.rb:122
  call_with_redirects at /Users/jclark/.rbenv/versions/jruby-1.7.22/lib/ruby/gems/shared/gems/hurley-0.2/lib/hurley/client.rb:127
                 call at /Users/jclark/.rbenv/versions/jruby-1.7.22/lib/ruby/gems/shared/gems/hurley-0.2/lib/hurley/client.rb:89
                  get at /Users/jclark/.rbenv/versions/jruby-1.7.22/lib/ruby/gems/shared/gems/hurley-0.2/lib/hurley/client.rb:47
                  get at /Users/jclark/.rbenv/versions/jruby-1.7.22/lib/ruby/1.9/forwardable.rb:201
               (root) at testing/hurley.rb:2
technoweenie commented 9 years ago

That seems to be coming from inside net/http. Can you post /Users/jclark/.rbenv/versions/jruby-1.7.22/lib/ruby/1.9/net/http.rb to a gist or something?

jasonrclark commented 9 years ago

Interesting. Confirmed that my local copy of that file is identical to the code at this tag in the JRuby repo: https://github.com/jruby/jruby/blob/1.7.22/lib/ruby/1.9/net/http.rb

technoweenie commented 9 years ago

FWIW this seems to be a ruby 1.9 bug: https://bugs.ruby-lang.org/issues/9467

technoweenie commented 9 years ago

I fixed it by skipping that net/http method that adds gzip encoding support for ruby 1.9 in #29. I'll push out a new release once the next two PRs are taken care of.

jasonrclark commented 9 years ago

Checked it out locally against master, and it worked great. Thanks @technoweenie!