diff options
author | danielsdeleo <dan@opscode.com> | 2013-10-03 19:16:26 -0700 |
---|---|---|
committer | danielsdeleo <dan@opscode.com> | 2013-10-08 15:01:47 -0700 |
commit | 1cf066b656daf8c0035d2f18ef5ffa33261d0ce9 (patch) | |
tree | ae522e7b47e2b6eb2d06d4b1dd8d1d6bdf89ea25 | |
parent | bd0e9fe142474944516bffdad625bb6bd9c34adc (diff) | |
download | chef-1cf066b656daf8c0035d2f18ef5ffa33261d0ce9.tar.gz |
Move HTTP components into chef/http
-rw-r--r-- | lib/chef/http.rb (renamed from lib/chef/rest/http.rb) | 6 | ||||
-rw-r--r-- | lib/chef/http/auth_credentials.rb (renamed from lib/chef/rest/auth_credentials.rb) | 2 | ||||
-rw-r--r-- | lib/chef/http/authenticator.rb (renamed from lib/chef/rest/authenticator.rb) | 4 | ||||
-rw-r--r-- | lib/chef/http/cookie_jar.rb (renamed from lib/chef/rest/cookie_jar.rb) | 2 | ||||
-rw-r--r-- | lib/chef/http/decompressor.rb (renamed from lib/chef/rest/decompressor.rb) | 6 | ||||
-rw-r--r-- | lib/chef/http/http_request.rb (renamed from lib/chef/rest/rest_request.rb) | 6 | ||||
-rw-r--r-- | lib/chef/http/json_to_model_inflater.rb (renamed from lib/chef/rest/json_to_model_inflater.rb) | 2 | ||||
-rw-r--r-- | lib/chef/rest.rb | 16 |
8 files changed, 23 insertions, 21 deletions
diff --git a/lib/chef/rest/http.rb b/lib/chef/http.rb index 174427523f..90199e9246 100644 --- a/lib/chef/rest/http.rb +++ b/lib/chef/http.rb @@ -23,7 +23,7 @@ require 'net/https' require 'uri' -require 'chef/rest/rest_request' +require 'chef/http/http_request' require 'chef/monkey_patches/string' require 'chef/monkey_patches/net_http' require 'chef/config' @@ -55,7 +55,7 @@ class Chef # HTTP GET request to http://localhost:4000/nodes def initialize(url, options={}) @url = url - @cookies = REST::CookieJar.instance + @cookies = HTTP::CookieJar.instance @default_headers = options[:headers] || {} @sign_on_redirect = true @redirects_followed = 0 @@ -188,7 +188,7 @@ class Chef end def retriable_http_request(method, url, req_body, headers) - rest_request = Chef::REST::RESTRequest.new(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}") diff --git a/lib/chef/rest/auth_credentials.rb b/lib/chef/http/auth_credentials.rb index 00711c960d..bd73524b1f 100644 --- a/lib/chef/rest/auth_credentials.rb +++ b/lib/chef/http/auth_credentials.rb @@ -24,7 +24,7 @@ require 'chef/log' require 'mixlib/authentication/signedheaderauth' class Chef - class REST + class HTTP class AuthCredentials attr_reader :client_name, :key diff --git a/lib/chef/rest/authenticator.rb b/lib/chef/http/authenticator.rb index 13f33cde25..006b5d890a 100644 --- a/lib/chef/rest/authenticator.rb +++ b/lib/chef/http/authenticator.rb @@ -16,12 +16,12 @@ # limitations under the License. # -require 'chef/rest/auth_credentials' +require 'chef/http/auth_credentials' require 'chef/exceptions' require 'openssl' class Chef - class REST + class HTTP class Authenticator attr_reader :signing_key_filename diff --git a/lib/chef/rest/cookie_jar.rb b/lib/chef/http/cookie_jar.rb index e3137708a2..418fb1d352 100644 --- a/lib/chef/rest/cookie_jar.rb +++ b/lib/chef/http/cookie_jar.rb @@ -23,7 +23,7 @@ require 'singleton' class Chef - class REST + class HTTP class CookieJar < Hash include Singleton end diff --git a/lib/chef/rest/decompressor.rb b/lib/chef/http/decompressor.rb index 1ce586a36a..846a29db0a 100644 --- a/lib/chef/rest/decompressor.rb +++ b/lib/chef/http/decompressor.rb @@ -17,10 +17,10 @@ # require 'zlib' -require 'chef/rest/rest_request' +require 'chef/http/http_request' class Chef - class REST + class HTTP # Middleware-esque class for handling compression in HTTP responses. class Decompressor @@ -41,7 +41,7 @@ class Chef end def handle_request(method, url, headers={}, data=false) - headers[RESTRequest::ACCEPT_ENCODING] = RESTRequest::ENCODING_GZIP_DEFLATE unless gzip_disabled? + headers[HTTPRequest::ACCEPT_ENCODING] = HTTPRequest::ENCODING_GZIP_DEFLATE unless gzip_disabled? [method, url, headers, data] end diff --git a/lib/chef/rest/rest_request.rb b/lib/chef/http/http_request.rb index ff9738de99..e92d834b9e 100644 --- a/lib/chef/rest/rest_request.rb +++ b/lib/chef/http/http_request.rb @@ -22,7 +22,7 @@ # require 'uri' require 'net/http' -require 'chef/rest/cookie_jar' +require 'chef/http/cookie_jar' # To load faster, we only want ohai's version string. # However, in ohai before 0.6.0, the version is defined @@ -36,8 +36,8 @@ end require 'chef/version' class Chef - class REST - class RESTRequest + class HTTP + class HTTPRequest engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby" diff --git a/lib/chef/rest/json_to_model_inflater.rb b/lib/chef/http/json_to_model_inflater.rb index f68cc76d37..bcdc5647aa 100644 --- a/lib/chef/rest/json_to_model_inflater.rb +++ b/lib/chef/http/json_to_model_inflater.rb @@ -18,7 +18,7 @@ require 'chef/json_compat' class Chef - class REST + class HTTP # A Middleware-ish thing that takes an HTTP response, parses it as JSON if # possible, and converts it into an appropriate model object if it contains diff --git a/lib/chef/rest.rb b/lib/chef/rest.rb index f1ab9bb10e..03ebb99152 100644 --- a/lib/chef/rest.rb +++ b/lib/chef/rest.rb @@ -20,18 +20,16 @@ # limitations under the License. # +require 'tempfile' +require 'chef/http' class Chef - # :nodoc: - # Ensure that we initialiaze Chef::REST with the right superclass. class HTTP; end class REST < HTTP; end end -require 'tempfile' -require 'chef/rest/http' -require 'chef/rest/authenticator' -require 'chef/rest/decompressor' -require 'chef/rest/json_to_model_inflater' +require 'chef/http/authenticator' +require 'chef/http/decompressor' +require 'chef/http/json_to_model_inflater' require 'chef/config' require 'chef/exceptions' require 'chef/platform/query_helpers' @@ -42,6 +40,10 @@ class Chef # authentication. class REST < HTTP + # Backwards compatibility for things that use + # Chef::REST::RESTRequest or its constants + RESTRequest = HTTP::HTTPRequest + attr_accessor :url, :cookies, :sign_on_redirect, :redirect_limit attr_reader :authenticator |