diff options
Diffstat (limited to 'lib/chef/http')
-rw-r--r-- | lib/chef/http/auth_credentials.rb | 4 | ||||
-rw-r--r-- | lib/chef/http/authenticator.rb | 8 | ||||
-rw-r--r-- | lib/chef/http/basic_client.rb | 12 | ||||
-rw-r--r-- | lib/chef/http/cookie_jar.rb | 2 | ||||
-rw-r--r-- | lib/chef/http/cookie_manager.rb | 8 | ||||
-rw-r--r-- | lib/chef/http/decompressor.rb | 6 | ||||
-rw-r--r-- | lib/chef/http/http_request.rb | 16 | ||||
-rw-r--r-- | lib/chef/http/json_input.rb | 6 | ||||
-rw-r--r-- | lib/chef/http/json_output.rb | 8 | ||||
-rw-r--r-- | lib/chef/http/json_to_model_output.rb | 2 | ||||
-rw-r--r-- | lib/chef/http/remote_request_id.rb | 4 | ||||
-rw-r--r-- | lib/chef/http/simple.rb | 10 | ||||
-rw-r--r-- | lib/chef/http/simple_json.rb | 10 | ||||
-rw-r--r-- | lib/chef/http/socketless_chef_zero_client.rb | 104 | ||||
-rw-r--r-- | lib/chef/http/ssl_policies.rb | 6 | ||||
-rw-r--r-- | lib/chef/http/validate_content_length.rb | 16 |
16 files changed, 111 insertions, 111 deletions
diff --git a/lib/chef/http/auth_credentials.rb b/lib/chef/http/auth_credentials.rb index bd73524b1f..c583352cfd 100644 --- a/lib/chef/http/auth_credentials.rb +++ b/lib/chef/http/auth_credentials.rb @@ -20,8 +20,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # -require 'chef/log' -require 'mixlib/authentication/signedheaderauth' +require "chef/log" +require "mixlib/authentication/signedheaderauth" class Chef class HTTP diff --git a/lib/chef/http/authenticator.rb b/lib/chef/http/authenticator.rb index bffa9c4b3a..02074171f8 100644 --- a/lib/chef/http/authenticator.rb +++ b/lib/chef/http/authenticator.rb @@ -16,9 +16,9 @@ # limitations under the License. # -require 'chef/http/auth_credentials' -require 'chef/exceptions' -require 'openssl' +require "chef/http/auth_credentials" +require "chef/exceptions" +require "openssl" class Chef class HTTP @@ -48,7 +48,7 @@ class Chef def handle_request(method, url, headers={}, data=false) headers.merge!(authentication_headers(method, url, data)) if sign_requests? - headers.merge!({'X-Ops-Server-API-Version' => @api_version}) + headers.merge!({"X-Ops-Server-API-Version" => @api_version}) [method, url, headers, data] end diff --git a/lib/chef/http/basic_client.rb b/lib/chef/http/basic_client.rb index de5e7c03a8..defa4976d1 100644 --- a/lib/chef/http/basic_client.rb +++ b/lib/chef/http/basic_client.rb @@ -20,10 +20,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # -require 'uri' -require 'net/http' -require 'chef/http/ssl_policies' -require 'chef/http/http_request' +require "uri" +require "net/http" +require "chef/http/ssl_policies" +require "chef/http/http_request" class Chef class HTTP @@ -72,7 +72,7 @@ class Chef Chef::Log.debug("---- End HTTP Status/Header Data ----") # For non-400's, log the request and response bodies - if !response.code || !response.code.start_with?('2') + if !response.code || !response.code.start_with?("2") if response.body Chef::Log.debug("---- HTTP Response Body ----") Chef::Log.debug(response.body) @@ -111,7 +111,7 @@ class Chef end end - no_proxy = Chef::Config[:no_proxy] || env['NO_PROXY'] || env['no_proxy'] + 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}:*" } return proxy unless excludes.any? { |exclude| File.fnmatch(exclude, "#{host}:#{port}") } diff --git a/lib/chef/http/cookie_jar.rb b/lib/chef/http/cookie_jar.rb index 418fb1d352..3f6d879c1f 100644 --- a/lib/chef/http/cookie_jar.rb +++ b/lib/chef/http/cookie_jar.rb @@ -20,7 +20,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -require 'singleton' +require "singleton" class Chef class HTTP diff --git a/lib/chef/http/cookie_manager.rb b/lib/chef/http/cookie_manager.rb index e9cb7aa4f7..4b48352382 100644 --- a/lib/chef/http/cookie_manager.rb +++ b/lib/chef/http/cookie_manager.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'chef/http/cookie_jar' +require "chef/http/cookie_jar" class Chef class HTTP @@ -34,14 +34,14 @@ class Chef 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}"] + headers["Cookie"] = @cookies["#{@host}:#{@port}"] end [method, url, headers, data] end def handle_response(http_response, rest_request, return_value) - if http_response['set-cookie'] - @cookies["#{@host}:#{@port}"] = http_response['set-cookie'] + if http_response["set-cookie"] + @cookies["#{@host}:#{@port}"] = http_response["set-cookie"] end [http_response, rest_request, return_value] end diff --git a/lib/chef/http/decompressor.rb b/lib/chef/http/decompressor.rb index a61f510e7d..bc033cc35e 100644 --- a/lib/chef/http/decompressor.rb +++ b/lib/chef/http/decompressor.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'zlib' -require 'chef/http/http_request' +require "zlib" +require "chef/http/http_request" class Chef class HTTP @@ -132,7 +132,7 @@ class Chef def handle_options(opts) opts.each do |name, value| case name.to_s - when 'disable_gzip' + when "disable_gzip" @disable_gzip = value end end diff --git a/lib/chef/http/http_request.rb b/lib/chef/http/http_request.rb index 9e48f6e5e9..891ffef05e 100644 --- a/lib/chef/http/http_request.rb +++ b/lib/chef/http/http_request.rb @@ -20,19 +20,19 @@ # See the License for the specific language governing permissions and # limitations under the License. # -require 'uri' -require 'net/http' +require "uri" +require "net/http" # To load faster, we only want ohai's version string. # However, in ohai before 0.6.0, the version is defined # in ohai, not ohai/version begin - require 'ohai/version' #used in user agent string. + require "ohai/version" #used in user agent string. rescue LoadError - require 'ohai' + require "ohai" end -require 'chef/version' +require "chef/version" class Chef class HTTP @@ -60,7 +60,7 @@ class Chef HOST_LOWER = "host".freeze - URI_SCHEME_DEFAULT_PORT = { 'http' => 80, 'https' => 443 }.freeze + URI_SCHEME_DEFAULT_PORT = { "http" => 80, "https" => 443 }.freeze def self.user_agent=(ua) @user_agent = ua @@ -139,13 +139,13 @@ class Chef @headers = headers.dup # No response compression unless we asked for it explicitly: @headers[HTTPRequest::ACCEPT_ENCODING] ||= "identity" - @headers['X-Chef-Version'] = ::Chef::VERSION + @headers["X-Chef-Version"] = ::Chef::VERSION # Only include port in Host header when it is not the default port # 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 diff --git a/lib/chef/http/json_input.rb b/lib/chef/http/json_input.rb index 3296d8821f..3bfca38479 100644 --- a/lib/chef/http/json_input.rb +++ b/lib/chef/http/json_input.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'chef/json_compat' +require "chef/json_compat" class Chef class HTTP @@ -33,8 +33,8 @@ class Chef 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' + headers.delete_if { |key, _value| key.downcase == "content-type" } + headers["Content-Type"] = "application/json" json_opts = {} json_opts[:validate_utf8] = opts[:validate_utf8] if opts.has_key?(:validate_utf8) data = Chef::JSONCompat.to_json(data, json_opts) diff --git a/lib/chef/http/json_output.rb b/lib/chef/http/json_output.rb index 069eb6a87f..86165d3d55 100644 --- a/lib/chef/http/json_output.rb +++ b/lib/chef/http/json_output.rb @@ -17,8 +17,8 @@ # limitations under the License. # -require 'chef/json_compat' -require 'chef/log' +require "chef/json_compat" +require "chef/log" class Chef class HTTP @@ -38,7 +38,7 @@ class Chef # 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. - headers['Accept'] ||= 'application/json' + headers["Accept"] ||= "application/json" [method, url, headers, data] end @@ -46,7 +46,7 @@ class Chef # temporary hack, skip processing if return_value is false # needed to keep conditional get stuff working correctly. return [http_response, rest_request, return_value] if return_value == false - if http_response['content-type'] =~ /json/ + if http_response["content-type"] =~ /json/ if http_response.body.nil? return_value = nil elsif raw_output diff --git a/lib/chef/http/json_to_model_output.rb b/lib/chef/http/json_to_model_output.rb index 9bc90a52ae..2290c90b0c 100644 --- a/lib/chef/http/json_to_model_output.rb +++ b/lib/chef/http/json_to_model_output.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'chef/http/json_output' +require "chef/http/json_output" class Chef class HTTP diff --git a/lib/chef/http/remote_request_id.rb b/lib/chef/http/remote_request_id.rb index 6bec5dba4f..bfee5d3ded 100644 --- a/lib/chef/http/remote_request_id.rb +++ b/lib/chef/http/remote_request_id.rb @@ -15,7 +15,7 @@ # limitations under the License. # -require 'chef/request_id' +require "chef/request_id" class Chef class HTTP @@ -25,7 +25,7 @@ class Chef end def handle_request(method, url, headers={}, data=false) - headers.merge!({'X-REMOTE-REQUEST-ID' => Chef::RequestID.instance.request_id}) + headers.merge!({"X-REMOTE-REQUEST-ID" => Chef::RequestID.instance.request_id}) [method, url, headers, data] end diff --git a/lib/chef/http/simple.rb b/lib/chef/http/simple.rb index f59fcaa08b..d828e98186 100644 --- a/lib/chef/http/simple.rb +++ b/lib/chef/http/simple.rb @@ -16,11 +16,11 @@ # limitations under the License. # -require 'chef/http' -require 'chef/http/authenticator' -require 'chef/http/decompressor' -require 'chef/http/cookie_manager' -require 'chef/http/validate_content_length' +require "chef/http" +require "chef/http/authenticator" +require "chef/http/decompressor" +require "chef/http/cookie_manager" +require "chef/http/validate_content_length" class Chef class HTTP diff --git a/lib/chef/http/simple_json.rb b/lib/chef/http/simple_json.rb index 5dfdfbb680..5c5a87d387 100644 --- a/lib/chef/http/simple_json.rb +++ b/lib/chef/http/simple_json.rb @@ -16,11 +16,11 @@ # limitations under the License. # -require 'chef/http' -require 'chef/http/authenticator' -require 'chef/http/decompressor' -require 'chef/http/cookie_manager' -require 'chef/http/validate_content_length' +require "chef/http" +require "chef/http/authenticator" +require "chef/http/decompressor" +require "chef/http/cookie_manager" +require "chef/http/validate_content_length" class Chef class HTTP diff --git a/lib/chef/http/socketless_chef_zero_client.rb b/lib/chef/http/socketless_chef_zero_client.rb index 8f5543a16f..e81aff6fce 100644 --- a/lib/chef/http/socketless_chef_zero_client.rb +++ b/lib/chef/http/socketless_chef_zero_client.rb @@ -43,7 +43,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -require 'chef_zero/server' +require "chef_zero/server" class Chef class HTTP @@ -81,56 +81,56 @@ class Chef # # HTTP status codes and descriptions STATUS_MESSAGE = { - 100 => 'Continue', - 101 => 'Switching Protocols', - 200 => 'OK', - 201 => 'Created', - 202 => 'Accepted', - 203 => 'Non-Authoritative Information', - 204 => 'No Content', - 205 => 'Reset Content', - 206 => 'Partial Content', - 207 => 'Multi-Status', - 300 => 'Multiple Choices', - 301 => 'Moved Permanently', - 302 => 'Found', - 303 => 'See Other', - 304 => 'Not Modified', - 305 => 'Use Proxy', - 307 => 'Temporary Redirect', - 400 => 'Bad Request', - 401 => 'Unauthorized', - 402 => 'Payment Required', - 403 => 'Forbidden', - 404 => 'Not Found', - 405 => 'Method Not Allowed', - 406 => 'Not Acceptable', - 407 => 'Proxy Authentication Required', - 408 => 'Request Timeout', - 409 => 'Conflict', - 410 => 'Gone', - 411 => 'Length Required', - 412 => 'Precondition Failed', - 413 => 'Request Entity Too Large', - 414 => 'Request-URI Too Large', - 415 => 'Unsupported Media Type', - 416 => 'Request Range Not Satisfiable', - 417 => 'Expectation Failed', - 422 => 'Unprocessable Entity', - 423 => 'Locked', - 424 => 'Failed Dependency', - 426 => 'Upgrade Required', - 428 => 'Precondition Required', - 429 => 'Too Many Requests', - 431 => 'Request Header Fields Too Large', - 500 => 'Internal Server Error', - 501 => 'Not Implemented', - 502 => 'Bad Gateway', - 503 => 'Service Unavailable', - 504 => 'Gateway Timeout', - 505 => 'HTTP Version Not Supported', - 507 => 'Insufficient Storage', - 511 => 'Network Authentication Required', + 100 => "Continue", + 101 => "Switching Protocols", + 200 => "OK", + 201 => "Created", + 202 => "Accepted", + 203 => "Non-Authoritative Information", + 204 => "No Content", + 205 => "Reset Content", + 206 => "Partial Content", + 207 => "Multi-Status", + 300 => "Multiple Choices", + 301 => "Moved Permanently", + 302 => "Found", + 303 => "See Other", + 304 => "Not Modified", + 305 => "Use Proxy", + 307 => "Temporary Redirect", + 400 => "Bad Request", + 401 => "Unauthorized", + 402 => "Payment Required", + 403 => "Forbidden", + 404 => "Not Found", + 405 => "Method Not Allowed", + 406 => "Not Acceptable", + 407 => "Proxy Authentication Required", + 408 => "Request Timeout", + 409 => "Conflict", + 410 => "Gone", + 411 => "Length Required", + 412 => "Precondition Failed", + 413 => "Request Entity Too Large", + 414 => "Request-URI Too Large", + 415 => "Unsupported Media Type", + 416 => "Request Range Not Satisfiable", + 417 => "Expectation Failed", + 422 => "Unprocessable Entity", + 423 => "Locked", + 424 => "Failed Dependency", + 426 => "Upgrade Required", + 428 => "Precondition Required", + 429 => "Too Many Requests", + 431 => "Request Header Fields Too Large", + 500 => "Internal Server Error", + 501 => "Not Implemented", + 502 => "Bad Gateway", + 503 => "Service Unavailable", + 504 => "Gateway Timeout", + 505 => "HTTP Version Not Supported", + 507 => "Insufficient Storage", + 511 => "Network Authentication Required", } STATUS_MESSAGE.values.each {|v| v.freeze } @@ -175,7 +175,7 @@ class Chef end def to_net_http(code, headers, chunked_body) - body = chunked_body.join('') + body = chunked_body.join("") msg = STATUS_MESSAGE[code] or raise "Cannot determine HTTP status message for code #{code}" response = Net::HTTPResponse.send(:response_class, code.to_s).new("1.0", code.to_s, msg) response.instance_variable_set(:@body, body) diff --git a/lib/chef/http/ssl_policies.rb b/lib/chef/http/ssl_policies.rb index 9c180c154e..5247d677cc 100644 --- a/lib/chef/http/ssl_policies.rb +++ b/lib/chef/http/ssl_policies.rb @@ -21,8 +21,8 @@ # limitations under the License. # -require 'openssl' -require 'chef/util/path_helper' +require "openssl" +require "chef/util/path_helper" class Chef class HTTP @@ -110,7 +110,7 @@ class Chef def add_trusted_cert(cert) http_client.cert_store.add_cert(cert) rescue OpenSSL::X509::StoreError => e - raise e unless e.message == 'cert already in hash table' + raise e unless e.message == "cert already in hash table" end end diff --git a/lib/chef/http/validate_content_length.rb b/lib/chef/http/validate_content_length.rb index 076194e31a..77fb6194ef 100644 --- a/lib/chef/http/validate_content_length.rb +++ b/lib/chef/http/validate_content_length.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'pp' -require 'chef/log' +require "pp" +require "chef/log" class Chef class HTTP @@ -73,18 +73,18 @@ class Chef private def response_content_length(response) - return nil if response['content-length'].nil? - if response['content-length'].is_a?(Array) - response['content-length'].first.to_i + return nil if response["content-length"].nil? + if response["content-length"].is_a?(Array) + response["content-length"].first.to_i else - response['content-length'].to_i + response["content-length"].to_i end end def validate(http_response, response_length) content_length = response_content_length(http_response) - transfer_encoding = http_response['transfer-encoding'] - content_encoding = http_response['content-encoding'] + transfer_encoding = http_response["transfer-encoding"] + content_encoding = http_response["content-encoding"] if content_length.nil? Chef::Log.debug "HTTP server did not include a Content-Length header in response, cannot identify truncated downloads." |