Only use continue-at with partial requests

This commit is contained in:
cnnrmnn 2021-05-13 12:27:54 -04:00
parent df0915e33f
commit 7637fd5366

View File

@ -134,7 +134,7 @@ module Utils
"--head", *args, **options).stdout "--head", *args, **options).stdout
headers = parse_headers(range_stdout.split("\r\n\r\n").first) 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. # Its absence indicates no support.
supports_partial = headers["accept-ranges"] && headers["accept-ranges"] != "none" supports_partial = headers["accept-ranges"] && headers["accept-ranges"] != "none"
@ -145,15 +145,12 @@ module Utils
end end
end end
continue_at = if destination.exist? && supports_partial
"-"
else
0
end
curl( args += ["--location", "--remote-time", "--output", destination]
"--location", "--remote-time", "--continue-at", continue_at.to_s, "--output", destination, *args, **options # 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 end
def curl_output(*args, **options) def curl_output(*args, **options)