Skip to content

Strange problem on OS X#242

Merged
taf2 merged 1 commit intotaf2:masterfrom
forresty:fix-os-x
Mar 25, 2015
Merged

Strange problem on OS X#242
taf2 merged 1 commit intotaf2:masterfrom
forresty:fix-os-x

Conversation

@forresty
Copy link
Copy Markdown
Contributor

Hi,

I encountered strange issue on OS X version 10.9.5 with Ruby version 2.1.3, 2.2.0 and 2.2.1

> irb ./play.rb
play.rb(main):001:0> require 'curb'
=> true
play.rb(main):002:0> url = 'http://baidu.com'
=> "http://baidu.com"
play.rb(main):003:0> client = Curl::Easy.new
=> #<Curl::Easy>
play.rb(main):004:0> client.url = url
=> "http://baidu.com"
play.rb(main):005:0> client.http_get
Curl::Err::GotNothingError: Server returned nothing (no headers, no data)
    from /Users/forresty/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/curb-0.8.7/lib/curl/easy.rb:72:in `perform'
    from /Users/forresty/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/curb-0.8.7/lib/curl/easy.rb:294:in `http'
    from /Users/forresty/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/curb-0.8.7/lib/curl/easy.rb:294:in `http_get'
    from ./play.rb:5
    from /Users/forresty/.rbenv/versions/2.1.3/bin/irb:11:in `<main>'

I was able to fix this problem with this single line change. Though I've no idea why it works.

In other words, it might not be a good idea to merge this pull request

the problem lies with the ruby_curl_easy_set_opt call when calling Easy#http_get

therefore, when use Easy#http with :GET argument directly, there is no problem:

play.rb(main):001:0> require 'curb'
=> true
play.rb(main):002:0> url = 'http://baidu.com'
=> "http://baidu.com"
play.rb(main):003:0> client = Curl::Easy.new
=> #<Curl::Easy>
play.rb(main):004:0> client.url = url
=> "http://baidu.com"
play.rb(main):005:0> client.http :GET
=> true
play.rb(main):006:0> puts client.body_str
<html>
<meta http-equiv="refresh" content="0;url=http://www.baidu.com/">
</html>
=> nil

After the patch:

> irb ./play.rb
play.rb(main):001:0> require 'curb'
=> true
play.rb(main):002:0> url = 'http://baidu.com'
=> "http://baidu.com"
play.rb(main):003:0> client = Curl::Easy.new
=> #<Curl::Easy>
play.rb(main):004:0> client.url = url
=> "http://baidu.com"
play.rb(main):005:0> client.http_get
=> true
play.rb(main):006:0> puts client.body_str
<html>
<meta http-equiv="refresh" content="0;url=http://www.baidu.com/">
</html>
=> nil

@forresty
Copy link
Copy Markdown
Contributor Author

Additionally, this problem exists on both OS X bundled libcurl and homebrew counterpart, but not on my Ubuntu boxes.

 otool -L ext/curb_core.bundle                                                            
ext/curb_core.bundle:
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
    /usr/local/lib/libgmp.10.dylib (compatibility version 13.0.0, current version 13.0.0)
    /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
    /usr/lib/libcurl.4.dylib (compatibility version 7.0.0, current version 8.0.0)
 otool -L ~/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/curb-0.8.7/ext/curb_core.bundle
/Users/forresty/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/curb-0.8.7/ext/curb_core.bundle:
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
    /usr/local/lib/libgmp.10.dylib (compatibility version 13.0.0, current version 13.0.0)
    /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
    /usr/local/opt/curl/lib/libcurl.4.dylib (compatibility version 8.0.0, current version 8.0.0)
    /System/Library/Frameworks/LDAP.framework/Versions/A/LDAP (compatibility version 1.0.0, current version 2.4.0)
    /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)

@taf2
Copy link
Copy Markdown
Owner

taf2 commented Mar 25, 2015

thanks this look like the correct fix. merging and testing now.

taf2 added a commit that referenced this pull request Mar 25, 2015
@taf2 taf2 merged commit 63d3846 into taf2:master Mar 25, 2015
@forresty
Copy link
Copy Markdown
Contributor Author

thanks, do let me know if there is any problem 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants