Gop*_*aju 2 ruby ruby-on-rails httparty
我在rails中有一个方法可以将发布请求发送到第三方API.代码类似于以下内容:
data = HTTParty.post("url",
:headers=> {'Content-Type' => 'application/json'},
:body=> { update => true, first_name => "name" }
)
Run Code Online (Sandbox Code Playgroud)
这样,在一分钟之后,该过程终止,并出现以下错误.
<Net::HTTPGatewayTimeOut 504 GATEWAY_TIMEOUT readbody=true>
Run Code Online (Sandbox Code Playgroud)
设置默认值:
module HTTParty
default_timeout your_preferred_timeout
end
Run Code Online (Sandbox Code Playgroud)
或者单独设置:
data = HTTParty.post("url",
headers: {"Content-Type" => "application/json"},
body: {update => true, first_name => "name"},
timeout: your_preferred_timeout
)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1833 次 |
| 最近记录: |