summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/chef/cookbook_uploader.rb10
-rw-r--r--lib/chef/http/basic_client.rb2
-rw-r--r--lib/chef/http/http_request.rb2
3 files changed, 8 insertions, 6 deletions
diff --git a/lib/chef/cookbook_uploader.rb b/lib/chef/cookbook_uploader.rb
index 3ead26e56d..34a982f0fb 100644
--- a/lib/chef/cookbook_uploader.rb
+++ b/lib/chef/cookbook_uploader.rb
@@ -137,7 +137,7 @@ class Chef
timestamp = Time.now.utc.iso8601
file_contents = File.open(file, "rb") {|f| f.read}
# TODO - 5/28/2010, cw: make signing and sending the request streaming
- headers = { 'content-type' => 'application/x-binary', 'content-md5' => checksum64, :accept => 'application/json' }
+ headers = { 'content-type' => 'application/x-binary', 'content-md5' => checksum64, "accept" => 'application/json' }
if rest.signing_key
sign_obj = Mixlib::Authentication::SignedHeaderAuth.signing_object(
:http_method => :put,
@@ -150,10 +150,12 @@ class Chef
end
begin
- RestClient::Resource.new(url, :headers=>headers, :timeout=>1800, :open_timeout=>1800).put(file_contents)
+ Chef::HTTP::Simple.new(url, :headers=>headers).put(url, file_contents)
checksums_to_upload.delete(checksum)
- rescue RestClient::Exception => e
- Chef::Knife.ui.error("Failed to upload #@cookbook : #{e.message}\n#{e.response.body}")
+ rescue Net::HTTPServerException, Net::HTTPFatalError, Errno::ECONNREFUSED, Timeout::Error, Errno::ETIMEDOUT, SocketError => e
+ error_message = "Failed to upload #{file} (#{checksum}) to #{url} : #{e.message}"
+ error_message << "\n#{e.response.body}" if e.respond_to?(:response)
+ Chef::Knife.ui.error(error_message)
raise
end
end
diff --git a/lib/chef/http/basic_client.rb b/lib/chef/http/basic_client.rb
index c3421703d5..05ac662b7c 100644
--- a/lib/chef/http/basic_client.rb
+++ b/lib/chef/http/basic_client.rb
@@ -47,7 +47,7 @@ class Chef
end
def host
- @url.host
+ @url.hostname
end
def port
diff --git a/lib/chef/http/http_request.rb b/lib/chef/http/http_request.rb
index ec837f13f2..e0ec2233b9 100644
--- a/lib/chef/http/http_request.rb
+++ b/lib/chef/http/http_request.rb
@@ -76,7 +76,7 @@ class Chef
end
def host
- @url.host
+ @url.hostname
end
def port