在 ruby 中运行 Net::HTTP 发布请求。我在 Ubuntu 中使用终端并收到以下错误消息:
SocketError: getaddrinfo: Name or service not known
from /usr/lib/ruby/1.9.1/net/http.rb:762:in `initialize'
from /usr/lib/ruby/1.9.1/net/http.rb:762:in `open'
from /usr/lib/ruby/1.9.1/net/http.rb:762:in `block in connect'
from /usr/lib/ruby/1.9.1/timeout.rb:54:in `timeout'
from /usr/lib/ruby/1.9.1/timeout.rb:99:in `timeout'
from /usr/lib/ruby/1.9.1/net/http.rb:762:in `connect'
from /usr/lib/ruby/1.9.1/net/http.rb:755:in `do_start'
from /usr/lib/ruby/1.9.1/net/http.rb:744:in `start'
from /usr/lib/ruby/1.9.1/net/http.rb:1284:in `request'
from /usr/lib/ruby/1.9.1/net/http.rb:1307:in `send_entity'
from /usr/lib/ruby/1.9.1/net/http.rb:1096:in `post'
from (irb):356
from /usr/bin/irb:12:in `<main>'
运行以下代码:
uri = @@url
http = Net::HTTP.new(uri)
response = http.post('/', @@str)
puts response