summaryrefslogtreecommitdiff
path: root/lib/chef/http.rb
diff options
context:
space:
mode:
authorJohn Keiser <jkeiser@opscode.com>2013-10-09 12:26:27 -0700
committerJohn Keiser <jkeiser@opscode.com>2013-10-09 12:26:27 -0700
commita5337fcad5ed979078b6cf57c7e1e6ec8f0b76cf (patch)
tree11a5e98513f9496d3ce15a823e7a84cd4d178f58 /lib/chef/http.rb
parent836705dee684032baa85920c808a3eca5f5a8a87 (diff)
downloadchef-a5337fcad5ed979078b6cf57c7e1e6ec8f0b76cf.tar.gz
Use new Chef::ServerAPI API class in upload/download/diff
Diffstat (limited to 'lib/chef/http.rb')
-rw-r--r--lib/chef/http.rb19
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/chef/http.rb b/lib/chef/http.rb
index 50e0509b91..4852a3eb8a 100644
--- a/lib/chef/http.rb
+++ b/lib/chef/http.rb
@@ -94,7 +94,7 @@ class Chef
# === Parameters
# path:: path part of the request URL
def head(path, headers={})
- request(:HEAD, create_url(path), headers)
+ request(:HEAD, path, headers)
end
# Send an HTTP GET request to the path
@@ -102,7 +102,7 @@ class Chef
# === Parameters
# path:: The path to GET
def get(path, headers={})
- request(:GET, create_url(path), headers)
+ request(:GET, path, headers)
end
# Send an HTTP PUT request to the path
@@ -110,7 +110,7 @@ class Chef
# === Parameters
# path:: path part of the request URL
def put(path, json, headers={})
- request(:PUT, create_url(path), headers, json)
+ request(:PUT, path, headers, json)
end
# Send an HTTP POST request to the path
@@ -118,7 +118,7 @@ class Chef
# === Parameters
# path:: path part of the request URL
def post(path, json, headers={})
- request(:POST, create_url(path), headers, json)
+ request(:POST, path, headers, json)
end
# Send an HTTP DELETE request to the path
@@ -126,12 +126,13 @@ class Chef
# === Parameters
# path:: path part of the request URL
def delete(path, headers={})
- request(:DELETE, create_url(path), headers)
+ request(:DELETE, path, headers)
end
- # Makes an HTTP request to +url+ with the given +method+, +headers+, and
+ # Makes an HTTP request to +path+ with the given +method+, +headers+, and
# +data+ (if applicable).
- def request(method, url, headers={}, data=false)
+ def request(method, path, headers={}, data=false)
+ url = create_url(path)
method, url, headers, data = apply_request_middleware(method, url, headers, data)
response, rest_request, return_value = send_http_request(method, url, headers, data)
@@ -153,7 +154,8 @@ class Chef
#
# If no block is given, the tempfile is returned, which means it's up to
# you to unlink the tempfile when you're done with it.
- def streaming_request(url, headers, &block)
+ def streaming_request(path, headers={}, &block)
+ url = create_url(path)
response, rest_request, return_value = nil, nil, nil
tempfile = nil
@@ -192,6 +194,7 @@ class Chef
protected
def create_url(path)
+ return path if path.is_a?(URI)
if path =~ /^(http|https):\/\//
URI.parse(path)
else