我正在使用RestClient gem通过它向服务器发出get请求。问题是如何从客户端设置超时时间。
RestClient.get "http://127.0.0.1:7819/tokenize/word/stackoverflow"
我想将它设置为10秒。
先行致谢!!
我正在使用RestClient gem通过它向服务器发出get请求。问题是如何从客户端设置超时时间。
RestClient.get "http://127.0.0.1:7819/tokenize/word/stackoverflow"
我想将它设置为10秒。
先行致谢!!
你不需要进行任何猴子补丁。你可以直接使用 RestClient::Request
,例如:
RestClient::Request.execute(:method => :get, :url => url, :timeout => 10, :open_timeout => 10)
但请记住,最坏的情况是20秒。
RestClient::Resource.new('http://slow', :timeout => 10)
。 - Jing Li