【问题标题】:What is the difference between timeout and open timeout?超时和打开超时有什么区别?
【发布时间】:2013-04-17 12:59:50
【问题描述】:

在 Ruby RestClient gem 中,超时和打开超时功能有什么区别?

http://www.ruby-doc.org/gems/docs/w/wgibbs-rest-client-1.0.5/RestClient/Resource.html#method-i-open_timeout

我也没有从 gem 的 doc 文件中得到任何东西。

【问题讨论】:

    标签: ruby rest-client


    【解决方案1】:

    您正在阅读错误的文档(您的文档是 wgibbs-rest-client,自 2009 年以来未更新):here's the right one。但是那个也没有说什么区别,虽然很简单:

    :open_timeout 是打开连接的超时时间。如果您调用响应时间缓慢或不稳定的服务器,这将非常有用。

    :timeout 是读取答案的超时时间。这有助于确保您不会在读取过程中卡住一半,或者在您预期 5 KB 的 JSON 时不会卡住读取 5 MB 文件。

    【讨论】:

    • 谢谢....只是为了确认响应 = RestClient.get "abc/order_items/advanced_search?"相当于 response = RestClient::Request.execute(:method => :get, :url => "abc/order_items/advanced_search?", :timeout => 300)
    • 是的,RestClient.get 正在像这样调用execute:Request.execute(:method => :get, :url => url, :headers => headers, &block)
    猜你喜欢
    • 2011-10-18
    • 2019-06-26
    • 2011-10-17
    • 2012-03-31
    • 2016-04-26
    • 1970-01-01
    • 2012-05-06
    • 2018-10-10
    • 1970-01-01
    相关资源
    最近更新 更多