From 7637fd5366c72ecbed0cfb93ebfb4c5fb449d07a Mon Sep 17 00:00:00 2001 From: cnnrmnn Date: Thu, 13 May 2021 12:27:54 -0400 Subject: [PATCH] Only use continue-at with partial requests --- Library/Homebrew/utils/curl.rb | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/Library/Homebrew/utils/curl.rb b/Library/Homebrew/utils/curl.rb index 03045dbb43..65cbdbe92b 100644 --- a/Library/Homebrew/utils/curl.rb +++ b/Library/Homebrew/utils/curl.rb @@ -134,7 +134,7 @@ module Utils "--head", *args, **options).stdout headers = parse_headers(range_stdout.split("\r\n\r\n").first) - # Any value for `accept-ranges` other than none indicates that the server supports range requests. + # Any value for `accept-ranges` other than none indicates that the server supports partial requests. # Its absence indicates no support. supports_partial = headers["accept-ranges"] && headers["accept-ranges"] != "none" @@ -145,15 +145,12 @@ module Utils end end - continue_at = if destination.exist? && supports_partial - "-" - else - 0 - end - curl( - "--location", "--remote-time", "--continue-at", continue_at.to_s, "--output", destination, *args, **options - ) + args += ["--location", "--remote-time", "--output", destination] + # continue-at shouldn't be used with servers that don't support partial requests. + args += ["--continue-at", "-"] if destination.exist? && supports_partial + + curl(*args, **options) end def curl_output(*args, **options)