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
1 changed files with 3 additions and 2 deletions

View File

@ -41,6 +41,7 @@ function specfile.checksyntax() {
notify.note " * $specfile"
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
# (skip this test if no '%setup' section has been found)
@ -48,10 +49,10 @@ function specfile.checksyntax() {
notify.note "$(test.num2str). ${NOTE}"\
"url""${NORM}..."
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: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 "\
\`url': "$"redirect detected: replacing from \`$SPEC_URL' to \`${http_effective_url}'"
let "total_issues += 1";