bundler/lib/bundler/compact_index_client/updater.rb in rubygems-update-3.5.4 vs bundler/lib/bundler/compact_index_client/updater.rb in rubygems-update-3.5.5
- old
+ new
@@ -40,28 +40,28 @@
if response.is_a?(Gem::Net::HTTPPartialContent)
break false unless file.append(response.body.byteslice(1..-1))
else
file.write(response.body)
end
- CacheFile.write(etag_path, etag(response))
+ CacheFile.write(etag_path, etag_from_response(response))
true
end
end
# request without range header to get the full file or a 304 Not Modified
def replace(remote_path, local_path, etag_path)
etag = etag_path.read.tap(&:chomp!) if etag_path.file?
response = @fetcher.call(remote_path, request_headers(etag))
return true if response.is_a?(Gem::Net::HTTPNotModified)
CacheFile.write(local_path, response.body, parse_digests(response))
- CacheFile.write(etag_path, etag(response))
+ CacheFile.write(etag_path, etag_from_response(response))
end
def request_headers(etag, range_start = nil)
headers = {}
headers["Range"] = "bytes=#{range_start}-" if range_start
- headers["If-None-Match"] = etag if etag
+ headers["If-None-Match"] = %("#{etag}") if etag
headers
end
def etag_for_request(etag_path)
etag_path.read.tap(&:chomp!) if etag_path.file?
@@ -75,10 +75,10 @@
etag = file.md5.hexdigest
CacheFile.write(etag_path, etag)
etag
end
- def etag(response)
+ def etag_from_response(response)
return unless response["ETag"]
etag = response["ETag"].delete_prefix("W/")
return if etag.delete_prefix!('"') && !etag.delete_suffix!('"')
etag
end