check_port_source: download first kilobytes of file

Unfortunately, some sites do not support the HTTP/1.1 range header and
just serve the whole file, which takes it's time and may result in a
timeout.

Fixes #2819
This commit is contained in:
Christian Helmuth 2018-05-09 11:54:55 +02:00
parent d450573681
commit 0f7de9268d
1 changed files with 4 additions and 1 deletions

View File

@ -54,11 +54,14 @@ check: $(DOWNLOADS)
#
# Check plain remote file
#
# Try to download first kilobytes at maximum, which succeeds with return code 0
# on small files or "(63) Maximum file size exceeded" if the file is larger.
# We call curl a second time if the first check fails. This gives download
# sites time to reconsider their response and helps, for example, to check the
# qemu-usb port.
#
CURL_CMD = curl -f -L -k -r -2 --max-time 15 --retry 2 $(URL($*)) > /dev/null 2>&1
CURL_CMD = curl -s -f -L -k --max-filesize 200000 \
--max-time 15 --retry 1 $(URL($*)) > /dev/null || [ $$? -eq 63 ]
%.file:
$(VERBOSE)$(CURL_CMD) || (sleep 1; $(CURL_CMD))