Send a setup-php user agent and request compressed tool downloads (#1168)

Downloads used curl's default user agent and no Accept-Encoding, so
fallbacks to getcomposer.org transferred the full ~3.8MB phar instead of
~0.9MB gzipped, and could not be told apart from other curl traffic.
This commit is contained in:
Jordi Boggiano
2026-11-27 00:40:41 +05:30
committed by GitHub
parent 940ea09f22
commit 66f29b02f3
2 changed files with 4 additions and 1 deletions
+3
View File
@@ -263,6 +263,9 @@ add_tool() {
fi
else
[ -f "$tool_path" ] && sudo cp -a "$tool_path" "$tool_path.bak"
# Tools are single files, so let servers gzip them in transit when curl can decode it.
local curl_opts=("${curl_opts[@]}")
curl -V | grep -qw libz && curl_opts+=(--compressed)
status_code=$(get -v -e "$tool_path" "${url[@]}")
if [ "$status_code" != "200" ] && [[ "${url[0]}" =~ ^https://github\.com/[^/]+/[^/]+/releases/latest/download/[^/?#]+$ ]]; then
local release_url
+1 -1
View File
@@ -1,7 +1,7 @@
# Variables
export tick="✓"
export cross="✗"
export curl_opts=(-sL)
export curl_opts=(-sL -A "setup-php (+https://github.com/shivammathur/setup-php)")
export old_versions="5.[3-5]"
export jit_versions="8.[0-9]"
export php_builder_versions="8.[3-9]"