Class: AdsCommon::Http
- Inherits:
-
Object
- Object
- AdsCommon::Http
- Defined in:
- lib/ads_common/http.rb
Constant Summary collapse
- HTTP_READ_TIMEOUT =
HTTP read and open timeouts in seconds.
15 * 60
- HTTP_OPEN_TIMEOUT =
5 * 60
Class Method Summary collapse
-
.get(url, config, headers = nil) ⇒ Object
Performs a get on a URL, using all of the connection options in the client library, returning the response body as a string.
-
.get_response(url, config, headers = nil) ⇒ Object
Performs a get on a URL, using all of the connection options in the client library, returning a HTTPI::Response.
-
.get_stream(url, config, headers = nil, &block) ⇒ Object
Performs a get on a URL, using all of the connection options in the client library, sending the response piecemeal to the given block.
-
.post(url, data, config, headers = nil) ⇒ Object
Performs a post on a URL, using all of the connection options in the client library, returning the response body as a string.
-
.post_response(url, data, config, headers = nil) ⇒ Object
Performs a post on a URL, using all of the connection options in the client library, returning a HTTPI::Response.
-
.post_stream(url, data, config, headers = nil, &block) ⇒ Object
Performs a post on a URL, using all of the connection options in the client library, sending the response piecemeal to the given block.
-
.put(url, data, config, headers = nil) ⇒ Object
Performs a put on a URL, using all of the connection options in the client library, returning the response body as a string.
-
.put_response(url, data, config, headers = nil) ⇒ Object
Performs a put on a URL, using all of the connection options in the client library, returning a HTTPI::Response.
Class Method Details
.get(url, config, headers = nil) ⇒ Object
Performs a get on a URL, using all of the connection options in the client library, returning the response body as a string.
42 43 44 |
# File 'lib/ads_common/http.rb', line 42 def self.get(url, config, headers = nil) return get_response(url, config, headers).body end |
.get_response(url, config, headers = nil) ⇒ Object
Performs a get on a URL, using all of the connection options in the client library, returning a HTTPI::Response.
34 35 36 37 38 |
# File 'lib/ads_common/http.rb', line 34 def self.get_response(url, config, headers = nil) request = prepare_request(url, config, headers) response = HTTPI.get(request) return response end |
.get_stream(url, config, headers = nil, &block) ⇒ Object
Performs a get on a URL, using all of the connection options in the client library, sending the response piecemeal to the given block.
48 49 50 51 52 53 |
# File 'lib/ads_common/http.rb', line 48 def self.get_stream(url, config, headers = nil, &block) request = prepare_request(url, config, headers) request.on_body(&block) HTTPI.get(request) return nil end |
.post(url, data, config, headers = nil) ⇒ Object
Performs a post on a URL, using all of the connection options in the client library, returning the response body as a string.
64 65 66 |
# File 'lib/ads_common/http.rb', line 64 def self.post(url, data, config, headers = nil) return post_response(url, data, config, headers).body end |
.post_response(url, data, config, headers = nil) ⇒ Object
Performs a post on a URL, using all of the connection options in the client library, returning a HTTPI::Response.
57 58 59 60 |
# File 'lib/ads_common/http.rb', line 57 def self.post_response(url, data, config, headers = nil) request = prepare_request(url, config, headers, data) return HTTPI.post(request) end |
.post_stream(url, data, config, headers = nil, &block) ⇒ Object
Performs a post on a URL, using all of the connection options in the client library, sending the response piecemeal to the given block.
70 71 72 73 74 75 |
# File 'lib/ads_common/http.rb', line 70 def self.post_stream(url, data, config, headers = nil, &block) request = prepare_request(url, config, headers, data) request.on_body(&block) HTTPI.post(request) return nil end |
.put(url, data, config, headers = nil) ⇒ Object
Performs a put on a URL, using all of the connection options in the client library, returning the response body as a string.
86 87 88 |
# File 'lib/ads_common/http.rb', line 86 def self.put(url, data, config, headers = nil) return put_response(url, data, config, headers).body end |
.put_response(url, data, config, headers = nil) ⇒ Object
Performs a put on a URL, using all of the connection options in the client library, returning a HTTPI::Response.
79 80 81 82 |
# File 'lib/ads_common/http.rb', line 79 def self.put_response(url, data, config, headers = nil) request = prepare_request(url, config, headers, data) return HTTPI.put(request) end |