Class: BingAdsRubySdk::HttpClient
- Inherits:
-
Object
- Object
- BingAdsRubySdk::HttpClient
- Defined in:
- lib/bing_ads_ruby_sdk/http_client.rb
Constant Summary collapse
- HTTP_OPEN_TIMEOUT =
10
- HTTP_READ_TIMEOUT =
20
- HTTP_RETRY_COUNT_ON_TIMEOUT =
2
- HTTP_INTERVAL_RETRY_COUNT_ON_TIMEOUT =
1
- HTTP_ERRORS =
[Net::HTTPServerError, Net::HTTPClientError]
- CONNECTION_SETTINGS =
{ persistent: true, tcp_nodelay: true, retry_limit: HTTP_RETRY_COUNT_ON_TIMEOUT, idempotent: true, retry_interval: HTTP_INTERVAL_RETRY_COUNT_ON_TIMEOUT, connect_timeout: HTTP_OPEN_TIMEOUT, read_timeout: HTTP_READ_TIMEOUT, ssl_version: :TLSv1_2, ciphers: "TLSv1.2:!aNULL:!eNULL" }
Class Method Summary collapse
Class Method Details
.close_http_connections ⇒ Object
46 47 48 49 50 |
# File 'lib/bing_ads_ruby_sdk/http_client.rb', line 46 def close_http_connections http_connections.values.each do |connection| connection.reset end end |
.post(request) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/bing_ads_ruby_sdk/http_client.rb', line 27 def post(request) uri = URI(request.url) conn = connection(request.url) raw_response = conn.post( path: uri.path, body: request.content, headers: request.headers ) if contains_error?(raw_response) BingAdsRubySdk.log(:warn) { BingAdsRubySdk::LogMessage.new(raw_response.body).to_s } raise BingAdsRubySdk::Errors::ServerError, raw_response.body else BingAdsRubySdk.log(:debug) { BingAdsRubySdk::LogMessage.new(raw_response.body).to_s } end raw_response.body end |