Kong / unirest-ruby

Unirest in Ruby: Simplified, lightweight HTTP client library.
http://unirest.io/ruby
MIT License
364 stars 83 forks source link

NoMethodError thrown when given an invalid domain name #8

Closed stevenkaras closed 10 years ago

stevenkaras commented 10 years ago

On Ubuntu 1304/rvm/MRI 2.1, the following code results in a NoMethodError:

require 'unirest'
Unirest.get("http://foo.bar")

The internal SocketError should probably be raised up, or should mark the response as an error. I'm unsure of the intended behavior, otherwise I'd fork and fix.

subnetmarco commented 10 years ago

You're right - can you submit a pull request? That would help a lot.

stevenkaras commented 10 years ago

Soonest I can get around to it is this weekend.

I think the best fix is to restrict the rescue to only RestClientExceptions, so it catches the status code exceptions, but allows underlying socket errors/getaddrinfo errors to bubble up.

subnetmarco commented 10 years ago

Hey @stevenkaras just checking in if you were able to contribute to this issue.

stevenkaras commented 10 years ago

You guys already merged the commit that fixes the issue. Forgot to write the issue number in the commit message, otherwise this would already be closed.

99f66f106719e93ed5117fae7325e78aa73f026d

subnetmarco commented 10 years ago

Oh! Thanks!