diff options
author | danielsdeleo <dan@opscode.com> | 2013-10-04 17:27:51 -0700 |
---|---|---|
committer | danielsdeleo <dan@opscode.com> | 2013-10-08 15:01:48 -0700 |
commit | 3b169bddbc3ba5c9759e01a6438d70e34d264cf0 (patch) | |
tree | ace89ef2cd976409ddaef3390df4fcc33db28f5b /lib/chef/rest.rb | |
parent | 9a98be5ad08813d532694f95c480b0bcbecd0da6 (diff) | |
download | chef-3b169bddbc3ba5c9759e01a6438d70e34d264cf0.tar.gz |
HTTP client creates request objects.
Changes the structure of HTTP requests so that we create an HTTP client
object and then ask it to make requests. This allows for easier
customization of the HTTP client object, in particular enabling use to
make use of persistent connections.
Diffstat (limited to 'lib/chef/rest.rb')
-rw-r--r-- | lib/chef/rest.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/chef/rest.rb b/lib/chef/rest.rb index 9b1de5acdd..686535ac82 100644 --- a/lib/chef/rest.rb +++ b/lib/chef/rest.rb @@ -143,6 +143,20 @@ class Chef alias :raw_http_request :send_http_request + # Deprecated: + # Responsibilities of this method have been split up. The #http_client is + # now responsible for making individual requests, while + # #retrying_http_errors handles error/retry logic. + def retriable_http_request(method, url, req_body, headers) + rest_request = Chef::HTTP::HTTPRequest.new(method, url, req_body, headers) + + Chef::Log.debug("Sending HTTP Request via #{method} to #{url.host}:#{url.port}#{rest_request.path}") + + retrying_http_errors(url) do + yield rest_request + end + end + alias :retriable_rest_request :retriable_http_request # Makes a streaming download request. <b>Doesn't speak JSON.</b> @@ -200,6 +214,11 @@ class Chef ensure @authenticator.sign_request = true end + + def http_client + BasicClient.new(create_url(url)) + end + private def stream_to_tempfile(url, response) |