Change inititial partial request to HEAD request
This commit is contained in:
parent
321c165bd3
commit
aa989bd55a
@ -118,15 +118,15 @@ module Utils
|
|||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
def curl_download(*args, to: nil, partial: true, **options)
|
def curl_download(*args, to: nil, try_partial: true, **options)
|
||||||
destination = Pathname(to)
|
destination = Pathname(to)
|
||||||
destination.dirname.mkpath
|
destination.dirname.mkpath
|
||||||
|
|
||||||
if partial
|
if try_partial
|
||||||
range_stdout = curl_output("--location", "--range", "0-1",
|
range_stdout = curl_output("--location", "--range", "0-1",
|
||||||
"--dump-header", "-",
|
"--dump-header", "-",
|
||||||
"--write-out", "%\{http_code}",
|
"--write-out", "%\{http_code}",
|
||||||
"--output", "/dev/null", *args, **options).stdout
|
"--head", *args, **options).stdout
|
||||||
headers, _, http_status = range_stdout.partition("\r\n\r\n")
|
headers, _, http_status = range_stdout.partition("\r\n\r\n")
|
||||||
|
|
||||||
supports_partial_download = http_status.to_i == 206 # Partial Content
|
supports_partial_download = http_status.to_i == 206 # Partial Content
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user