法拉第超时

我在网上搜索了文档和其他地方,似乎无法想出为法拉第设置超时选项的正确方法。 有人有答案吗?

我试过了:

conn = FaradayStack.build(url) conn.headers[:user_agent] = AppConfig.user_agent # conn.options[:timeout] = 20 # conn.options[:open_timeout] = 20 response = conn.get do |req| req.options = { :timeout => 20, :open_timeout => 20 } end response.body 

似乎没有什么工作。 顺便说一句,我使用Typhoeus适配器,如果这有所作为。

好吧,我好像想通了。 如果我将超时选项传递给初始化程序,它似乎工作:

  options = { :timeout => 20, :open_timeout => 20 } conn = FaradayStack.build(url, options) conn.headers[:user_agent] = AppConfig.user_agent conn.get.body 

法拉第自述文件当前包含使用块样式的示例:

 conn.get do |req| req.url '/search' req.options[:timeout] = 5 # open/read timeout in seconds req.options[:open_timeout] = 2 # connection open timeout in seconds end 

如果这对您不起作用,也许您应该在Github上提交一张票。