diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2016-02-05 15:00:00 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2016-02-05 15:00:00 -0800 |
commit | 686113531d23f30e9973d659c456ae33eb9cff1f (patch) | |
tree | f225de7251a8b49b8d183dd168bab0a0addbe23f /lib/chef/http | |
parent | d1cf34b059a16a81e0fc48de52ba29863bb41fe6 (diff) | |
download | chef-686113531d23f30e9973d659c456ae33eb9cff1f.tar.gz |
autofixing whitespace cops
4174 Style/SpaceInsideHashLiteralBraces
1860 Style/SpaceAroundOperators
1336 Style/SpaceInsideBlockBraces
1292 Style/AlignHash
997 Style/SpaceAfterComma
860 Style/SpaceAroundEqualsInParameterDefault
310 Style/EmptyLines
294 Style/IndentationConsistency
267 Style/TrailingWhitespace
238 Style/ExtraSpacing
212 Style/SpaceBeforeBlockBraces
166 Style/MultilineOperationIndentation
144 Style/TrailingBlankLines
120 Style/EmptyLineBetweenDefs
101 Style/IndentationWidth
82 Style/SpaceAroundBlockParameters
40 Style/EmptyLinesAroundMethodBody
29 Style/EmptyLinesAroundAccessModifier
1 Style/RescueEnsureAlignment
Diffstat (limited to 'lib/chef/http')
-rw-r--r-- | lib/chef/http/auth_credentials.rb | 8 | ||||
-rw-r--r-- | lib/chef/http/authenticator.rb | 8 | ||||
-rw-r--r-- | lib/chef/http/basic_client.rb | 16 | ||||
-rw-r--r-- | lib/chef/http/cookie_manager.rb | 4 | ||||
-rw-r--r-- | lib/chef/http/decompressor.rb | 6 | ||||
-rw-r--r-- | lib/chef/http/http_request.rb | 7 | ||||
-rw-r--r-- | lib/chef/http/json_input.rb | 6 | ||||
-rw-r--r-- | lib/chef/http/json_output.rb | 4 | ||||
-rw-r--r-- | lib/chef/http/json_to_model_output.rb | 2 | ||||
-rw-r--r-- | lib/chef/http/remote_request_id.rb | 6 | ||||
-rw-r--r-- | lib/chef/http/socketless_chef_zero_client.rb | 5 | ||||
-rw-r--r-- | lib/chef/http/validate_content_length.rb | 4 |
12 files changed, 36 insertions, 40 deletions
diff --git a/lib/chef/http/auth_credentials.rb b/lib/chef/http/auth_credentials.rb index 3db8b1bfe8..d5dbff3758 100644 --- a/lib/chef/http/auth_credentials.rb +++ b/lib/chef/http/auth_credentials.rb @@ -28,7 +28,7 @@ class Chef class AuthCredentials attr_reader :client_name, :key - def initialize(client_name=nil, key=nil) + def initialize(client_name = nil, key = nil) @client_name, @key = client_name, key end @@ -36,7 +36,7 @@ class Chef !!key end - def signature_headers(request_params={}) + def signature_headers(request_params = {}) raise ArgumentError, "Cannot sign the request without a client name, check that :node_name is assigned" if client_name.nil? Chef::Log.debug("Signing the request as #{client_name}") @@ -48,8 +48,8 @@ class Chef host = request_params.delete(:host) || "localhost" sign_obj = Mixlib::Authentication::SignedHeaderAuth.signing_object(request_params) - signed = sign_obj.sign(key).merge({:host => host}) - signed.inject({}){|memo, kv| memo["#{kv[0].to_s.upcase}"] = kv[1];memo} + signed = sign_obj.sign(key).merge({ :host => host }) + signed.inject({}) { |memo, kv| memo["#{kv[0].to_s.upcase}"] = kv[1];memo } end end diff --git a/lib/chef/http/authenticator.rb b/lib/chef/http/authenticator.rb index d84f8dde55..970c19cd62 100644 --- a/lib/chef/http/authenticator.rb +++ b/lib/chef/http/authenticator.rb @@ -33,7 +33,7 @@ class Chef attr_accessor :sign_request - def initialize(opts={}) + def initialize(opts = {}) @raw_key = nil @sign_request = true @signing_key_filename = opts[:signing_key_filename] @@ -46,8 +46,8 @@ class Chef end end - def handle_request(method, url, headers={}, data=false) - headers.merge!({"X-Ops-Server-API-Version" => @api_version}) + def handle_request(method, url, headers = {}, data = false) + headers.merge!({ "X-Ops-Server-API-Version" => @api_version }) headers.merge!(authentication_headers(method, url, data, headers)) if sign_requests? [method, url, headers, data] end @@ -90,7 +90,7 @@ class Chef raise Chef::Exceptions::InvalidPrivateKey, msg end - def authentication_headers(method, url, json_body=nil, headers=nil) + def authentication_headers(method, url, json_body = nil, headers = nil) request_params = { :http_method => method, :path => url.path, diff --git a/lib/chef/http/basic_client.rb b/lib/chef/http/basic_client.rb index 5f0415996f..9428858cdf 100644 --- a/lib/chef/http/basic_client.rb +++ b/lib/chef/http/basic_client.rb @@ -40,7 +40,7 @@ class Chef # url:: An URI for the remote server. # === Options: # ssl_policy:: The SSL Policy to use, defaults to DefaultSSLPolicy - def initialize(url, opts={}) + def initialize(url, opts = {}) @url = url @ssl_policy = opts[:ssl_policy] || DefaultSSLPolicy @http_client = build_http_client @@ -54,7 +54,7 @@ class Chef @url.port end - def request(method, url, req_body, base_headers={}) + def request(method, url, req_body, base_headers = {}) http_request = HTTPRequest.new(method, url, req_body, base_headers).http_request Chef::Log.debug("Initiating #{method} to #{url}") Chef::Log.debug("---- HTTP Request Header Data: ----") @@ -105,12 +105,12 @@ class Chef # here since we are really just trying to get the string built correctly. if String === proxy && !proxy.strip.empty? if proxy.match(/^.*:\/\//) - proxy = URI.parse(proxy.strip) + proxy = URI.parse(proxy.strip) else - proxy = URI.parse("#{url.scheme}://#{proxy.strip}") - end + proxy = URI.parse("#{url.scheme}://#{proxy.strip}") + end end - + no_proxy = Chef::Config[:no_proxy] || env["NO_PROXY"] || env["no_proxy"] excludes = no_proxy.to_s.split(/\s*,\s*/).compact excludes = excludes.map { |exclude| exclude =~ /:\d+$/ ? exclude : "#{exclude}:*" } @@ -151,12 +151,12 @@ class Chef def http_proxy_user(http_proxy) http_proxy.user || Chef::Config["#{url.scheme}_proxy_user"] || - env["#{url.scheme.upcase}_PROXY_USER"] || env["#{url.scheme}_proxy_user"] + env["#{url.scheme.upcase}_PROXY_USER"] || env["#{url.scheme}_proxy_user"] end def http_proxy_pass(http_proxy) http_proxy.password || Chef::Config["#{url.scheme}_proxy_pass"] || - env["#{url.scheme.upcase}_PROXY_PASS"] || env["#{url.scheme}_proxy_pass"] + env["#{url.scheme.upcase}_PROXY_PASS"] || env["#{url.scheme}_proxy_pass"] end def configure_ssl(http_client) diff --git a/lib/chef/http/cookie_manager.rb b/lib/chef/http/cookie_manager.rb index a99a8f1cd9..18824a8eff 100644 --- a/lib/chef/http/cookie_manager.rb +++ b/lib/chef/http/cookie_manager.rb @@ -27,11 +27,11 @@ class Chef # it, so it's included with Chef::REST class CookieManager - def initialize(options={}) + def initialize(options = {}) @cookies = CookieJar.instance end - def handle_request(method, url, headers={}, data=false) + def handle_request(method, url, headers = {}, data = false) @host, @port = url.host, url.port if @cookies.has_key?("#{@host}:#{@port}") headers["Cookie"] = @cookies["#{@host}:#{@port}"] diff --git a/lib/chef/http/decompressor.rb b/lib/chef/http/decompressor.rb index c9b808861c..1bba4cc492 100644 --- a/lib/chef/http/decompressor.rb +++ b/lib/chef/http/decompressor.rb @@ -50,12 +50,12 @@ class Chef DEFLATE = "deflate".freeze IDENTITY = "identity".freeze - def initialize(opts={}) + def initialize(opts = {}) @disable_gzip = false handle_options(opts) end - def handle_request(method, url, headers={}, data=false) + def handle_request(method, url, headers = {}, data = false) headers[HTTPRequest::ACCEPT_ENCODING] = HTTPRequest::ENCODING_GZIP_DEFLATE unless gzip_disabled? [method, url, headers, data] end @@ -114,7 +114,6 @@ class Chef end end - # gzip is disabled using the disable_gzip => true option in the # constructor. When gzip is disabled, no 'Accept-Encoding' header will be # set, and the response will not be decompressed, no matter what the @@ -138,7 +137,6 @@ class Chef end end - end end end diff --git a/lib/chef/http/http_request.rb b/lib/chef/http/http_request.rb index 1590537f19..a1ef9b9ee2 100644 --- a/lib/chef/http/http_request.rb +++ b/lib/chef/http/http_request.rb @@ -72,7 +72,7 @@ class Chef attr_reader :method, :url, :headers, :http_client, :http_request - def initialize(method, url, req_body, base_headers={}) + def initialize(method, url, req_body, base_headers = {}) @method, @url = method, url @request_body = nil build_headers(base_headers) @@ -145,13 +145,12 @@ class Chef # for the url scheme (80;443) - Fixes CHEF-5355 host_header = uri_safe_host.dup host_header << ":#{port}" unless URI_SCHEME_DEFAULT_PORT[@url.scheme] == port.to_i - @headers["Host"] = host_header unless @headers.keys.any? {|k| k.downcase.to_s == HOST_LOWER } + @headers["Host"] = host_header unless @headers.keys.any? { |k| k.downcase.to_s == HOST_LOWER } @headers end - - def configure_http_request(request_body=nil) + def configure_http_request(request_body = nil) req_path = "#{path}" req_path << "?#{query}" if query diff --git a/lib/chef/http/json_input.rb b/lib/chef/http/json_input.rb index 2fd1501b1d..eaee96d88a 100644 --- a/lib/chef/http/json_input.rb +++ b/lib/chef/http/json_input.rb @@ -27,11 +27,11 @@ class Chef attr_accessor :opts - def initialize(opts={}) + def initialize(opts = {}) @opts = opts end - def handle_request(method, url, headers={}, data=false) + def handle_request(method, url, headers = {}, data = false) if data && should_encode_as_json?(headers) headers.delete_if { |key, _value| key.downcase == "content-type" } headers["Content-Type"] = "application/json" @@ -64,7 +64,7 @@ class Chef # ruby/Net::HTTP don't enforce capitalized headers (it normalizes them # for you before sending the request), so we have to account for all # the variations we might find - requested_content_type = headers.find {|k, v| k.downcase == "content-type" } + requested_content_type = headers.find { |k, v| k.downcase == "content-type" } requested_content_type.nil? || requested_content_type.last.include?("json") end diff --git a/lib/chef/http/json_output.rb b/lib/chef/http/json_output.rb index 6814fa1a55..6053c38a56 100644 --- a/lib/chef/http/json_output.rb +++ b/lib/chef/http/json_output.rb @@ -29,12 +29,12 @@ class Chef attr_accessor :raw_output attr_accessor :inflate_json_class - def initialize(opts={}) + def initialize(opts = {}) @raw_output = opts[:raw_output] @inflate_json_class = opts[:inflate_json_class] end - def handle_request(method, url, headers={}, data=false) + def handle_request(method, url, headers = {}, data = false) # Ideally this should always set Accept to application/json, but # Chef::REST is sometimes used to make non-JSON requests, so it sets # Accept to the desired value before middlewares get called. diff --git a/lib/chef/http/json_to_model_output.rb b/lib/chef/http/json_to_model_output.rb index 99878fe629..12ca1a90aa 100644 --- a/lib/chef/http/json_to_model_output.rb +++ b/lib/chef/http/json_to_model_output.rb @@ -25,7 +25,7 @@ class Chef # possible, and converts it into an appropriate model object if it contains # a `json_class` key. class JSONToModelOutput < JSONOutput - def initialize(opts={}) + def initialize(opts = {}) opts[:inflate_json_class] = true if !opts.has_key?(:inflate_json_class) super end diff --git a/lib/chef/http/remote_request_id.rb b/lib/chef/http/remote_request_id.rb index ba6108e063..ef8a18a1e3 100644 --- a/lib/chef/http/remote_request_id.rb +++ b/lib/chef/http/remote_request_id.rb @@ -21,11 +21,11 @@ class Chef class HTTP class RemoteRequestID - def initialize(opts={}) + def initialize(opts = {}) end - def handle_request(method, url, headers={}, data=false) - headers.merge!({"X-REMOTE-REQUEST-ID" => Chef::RequestID.instance.request_id}) + def handle_request(method, url, headers = {}, data = false) + headers.merge!({ "X-REMOTE-REQUEST-ID" => Chef::RequestID.instance.request_id }) [method, url, headers, data] end diff --git a/lib/chef/http/socketless_chef_zero_client.rb b/lib/chef/http/socketless_chef_zero_client.rb index ef2e8732cc..c8590903f6 100644 --- a/lib/chef/http/socketless_chef_zero_client.rb +++ b/lib/chef/http/socketless_chef_zero_client.rb @@ -133,7 +133,7 @@ class Chef 511 => "Network Authentication Required", } - STATUS_MESSAGE.values.each {|v| v.freeze } + STATUS_MESSAGE.values.each { |v| v.freeze } STATUS_MESSAGE.freeze def initialize(base_url) @@ -195,12 +195,11 @@ class Chef private def headers_extracted_from_options - options.reject {|name, _| KNOWN_OPTIONS.include?(name) }.map { |name, value| + options.reject { |name, _| KNOWN_OPTIONS.include?(name) }.map { |name, value| [name.to_s.split("_").map { |segment| segment.capitalize }.join("-"), value] } end - end end diff --git a/lib/chef/http/validate_content_length.rb b/lib/chef/http/validate_content_length.rb index c92360adfe..33b6d5a549 100644 --- a/lib/chef/http/validate_content_length.rb +++ b/lib/chef/http/validate_content_length.rb @@ -41,10 +41,10 @@ class Chef end end - def initialize(opts={}) + def initialize(opts = {}) end - def handle_request(method, url, headers={}, data=false) + def handle_request(method, url, headers = {}, data = false) [method, url, headers, data] end |