Last active
August 29, 2015 14:19
-
-
Save mudge/2a4f82b5be51541d9303 to your computer and use it in GitHub Desktop.
How to set request timeouts for various network clients
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Faraday.new(site, request: { timeout: 30 }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
new \GuzzleHttp\Client([ | |
'base_url' => $url, | |
'defaults' => ['timeout' => 1] | |
]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
new \Guzzle\Http\Client($url, ['request.options' => ['timeout' => 30]]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HTTParty.get(url, timeout: 30) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Koala.http_service.http_options = { | |
request: { timeout: 30 } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http = Net::HTTP.new(uri.host, uri.port) | |
http.read_timeout = 10 | |
http.open_timeout = 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OAuth2::Client.new(id, secret, site: site, connection_opts: { request: { timeout: 30 } }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# It doesn't look like RestClient.get supports passing timeouts | |
RestClient::Request.execute(method: :get, url: url, timeout: 30) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Typhoeus.get(url, timeout: 30) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment