#curl_download
: default try_partial
to false
#13179
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?When its
try_partial
argument istrue
,#curl_download
makes aHEAD
request before downloading the file using#curl
. Currentlytry_partial
defaults totrue
, so any#curl_download
call that doesn't explicitly specifytry_partial: false
will make aHEAD
request first. This can potentially involve several requests if the URL redirects, so it can be a bit of unnecessary overhead when a partial download isn't needed.Partial downloads are generally only useful when we're working with larger files, however there's currently only one place in brew where
#curl_download
is used and this is the case:CurlDownloadStrategy
. The other#curl_download
calls are fetching smaller [text] files and don't need to support partial downloads.This PR changes the default
try_partial
value tofalse
, making partial downloads opt-in rather than opt-out.We want
try_partial
to continue to default totrue
inCurlDownloadStrategy
and there are various ways to accomplish this. In this PR, I've chosen to update its#initialize
method to accept atry_partial
argument that defaults totrue
, as this value can also be used in classes that inherit fromCurlDownloadStrategy
(e.g.,HomebrewCurlDownloadStrategy
). This instance variable is passed to#curl_download
in related methods, effectively maintaining the previoustry_partial: true
value, while also allowing this value to be overridden when necessary.Other uses of
#curl_download
in brew areFormulary::FromUrlLoader#load_file
andCask::CaskLoader::FromURILoader#load
, which did not provide atry_partial
argument but should have been usingtry_partial: false
. With thetry_partial: false
default in this PR, these calls are now fine without atry_partial
argument.The only other use of
#curl_download
in brew isSPDX#download_latest_license_data!
. These calls were previously usingtry_partial: false
but we can now omit this argument with the newfalse
default (aligning with the above).