tests/test00_specsyntax: provide a fake user agent instead of culr default to prevent some sites from blocking

This commit is contained in:
Silvan Calarco 2022-01-06 14:25:46 +01:00
parent 4c108739a2
commit 8264d45caf

View File

@ -41,6 +41,7 @@ function specfile.checksyntax() {
notify.note " * $specfile" notify.note " * $specfile"
local total_issues=0 local total_issues=0
local user_agent="Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/81.0"
# 0. checking if 'Source[0]' is a valid internet address # 0. checking if 'Source[0]' is a valid internet address
# (skip this test if no '%setup' section has been found) # (skip this test if no '%setup' section has been found)
@ -48,10 +49,10 @@ function specfile.checksyntax() {
notify.note "$(test.num2str). ${NOTE}"\ notify.note "$(test.num2str). ${NOTE}"\
"url""${NORM}..." "url""${NORM}..."
if [[ "$SPEC_URL" ]]; then if [[ "$SPEC_URL" ]]; then
http_code=`curl -s -o /dev/null -w "%{http_code}" $SPEC_URL` http_code=`curl -s -o /dev/null -w "%{http_code}" -A "${user_agent}" $SPEC_URL`
if [ "$http_code" != "200" ]; then if [ "$http_code" != "200" ]; then
if [ "${http_code:0:2}" == "30" ]; then if [ "${http_code:0:2}" == "30" ]; then
http_effective_url=`curl -w "%{url_effective}" -I -L -s -o /dev/null -S $SPEC_URL` http_effective_url=`curl -w "%{url_effective}" -I -L -s -o /dev/null -A "${user_agent}" -S $SPEC_URL`
{ notify.warning "\ { notify.warning "\
\`url': "$"redirect detected: replacing from \`$SPEC_URL' to \`${http_effective_url}'" \`url': "$"redirect detected: replacing from \`$SPEC_URL' to \`${http_effective_url}'"
let "total_issues += 1"; let "total_issues += 1";