ruby - HTTP request error: name or service not known -


i trying make http requests via ruby. when running following code:

require "net/http" require "uri"  uri = uri.parse("http://google.com/")  # print response.body net::http.get_print(uri) 

i following error:

socketerror: initialize: name or service not known         org/jruby/ext/socket/rubytcpsocket.java:129:in `initialize'         org/jruby/rubyio.java:1179:in `open'         c:/jruby-1.7.3/lib/ruby/1.9/net/http.rb:762:in `connect'         org/jruby/ext/timeout/timeout.java:105:in `timeout'         c:/jruby-1.7.3/lib/ruby/1.9/net/http.rb:762:in `connect'         c:/jruby-1.7.3/lib/ruby/1.9/net/http.rb:755:in `do_start'         c:/jruby-1.7.3/lib/ruby/1.9/net/http.rb:744:in `start'         c:/jruby-1.7.3/lib/ruby/1.9/net/http.rb:454:in `get_response'         c:/jruby-1.7.3/lib/ruby/1.9/net/http.rb:412:in `get_print'         (irb):29:in `evaluate'         org/jruby/rubykernel.java:1066:in `eval'         org/jruby/rubykernel.java:1409:in `loop'         org/jruby/rubykernel.java:1174:in `catch'         org/jruby/rubykernel.java:1174:in `catch'         c:/jruby-1.7.3/bin/irb:13:in `(root)' 

this proxy related, not sure. how can fix problem?

ruby automatically use http proxy specified in environment variables.

export http_proxy=http://foo.bar:8080/ ruby your_http_script.rb 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -