summaryrefslogtreecommitdiff
path: root/lib/chef/http.rb
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2019-07-02 15:09:07 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2019-07-02 15:09:07 -0700
commit7a1a6c8ef26c787e4b6dd1602f3d158b37e81720 (patch)
tree1e390cd535b38368d091cbb33e5d419408d5ce00 /lib/chef/http.rb
parent77f8739a4741e2370e40ec39345a92a6ea393a1a (diff)
downloadchef-7a1a6c8ef26c787e4b6dd1602f3d158b37e81720.tar.gz
fix Layout/EmptyLineAfterGuardClause
i like this one, gives visual priority to returns or raises that are buried in the middle of things. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef/http.rb')
-rw-r--r--lib/chef/http.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/chef/http.rb b/lib/chef/http.rb
index f5ad71c694..546b9c0fbe 100644
--- a/lib/chef/http.rb
+++ b/lib/chef/http.rb
@@ -186,6 +186,7 @@ class Chef
apply_stream_complete_middleware(http_response, rest_request, return_value)
end
return nil if response.kind_of?(Net::HTTPRedirection)
+
unless response.kind_of?(Net::HTTPSuccess)
response.error!
end
@@ -233,6 +234,7 @@ class Chef
end
return nil if response.kind_of?(Net::HTTPRedirection)
+
unless response.kind_of?(Net::HTTPSuccess)
response.error!
end
@@ -309,6 +311,7 @@ class Chef
# @api private
def create_url(path)
return path if path.is_a?(URI)
+
if path =~ /^(http|https|chefzero):\/\//i
URI.parse(path)
elsif path.nil? || path.empty?
@@ -479,6 +482,7 @@ class Chef
# @api private
def follow_redirect
raise Chef::Exceptions::RedirectLimitExceeded if @redirects_followed >= redirect_limit
+
@redirects_followed += 1
Chef::Log.trace("Following redirect #{@redirects_followed}/#{redirect_limit}")
@@ -498,6 +502,7 @@ class Chef
return nil unless response.kind_of?(Net::HTTPRedirection)
# Net::HTTPNotModified is undesired subclass of Net::HTTPRedirection so test for this
return nil if response.kind_of?(Net::HTTPNotModified)
+
response["location"]
end