Merge pull request #13195 from samford/curl_http_content_headers_and_checksum-reinstate-old-return-behavior

Curl: Remove guard from certain parsing logic
This commit is contained in:
Mike McQuaid 2022-04-26 10:30:16 +01:00 committed by GitHub
commit 048f849895
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -345,20 +345,20 @@ module Utils
user_agent: user_agent
)
parsed_output = parse_curl_output(output)
responses = parsed_output[:responses]
final_url = curl_response_last_location(responses)
headers = if responses.last.present?
status_code = responses.last[:status_code]
responses.last[:headers]
else
{}
end
etag = headers["etag"][ETAG_VALUE_REGEX, 1] if headers["etag"].present?
content_length = headers["content-length"]
if status.success?
parsed_output = parse_curl_output(output)
responses = parsed_output[:responses]
final_url = curl_response_last_location(responses)
headers = if responses.last.present?
status_code = responses.last[:status_code]
responses.last[:headers]
else
{}
end
etag = headers["etag"][ETAG_VALUE_REGEX, 1] if headers["etag"].present?
content_length = headers["content-length"]
file_contents = File.read(file.path)
file_hash = Digest::SHA2.hexdigest(file_contents) if hash_needed
end