########################################################################
# #
# This software is part of the ast package #
# Copyright (c) 1994-2011 AT&T Intellectual Property #
# and is licensed under the #
# Eclipse Public License, Version 1.0 #
# by AT&T Intellectual Property #
# #
# A copy of the License is available at #
# (with md5 checksum b35adb5213ca9657e911e9befb180842) #
# #
# Information and Software Systems Research #
# AT&T Research #
# Florham Park NJ #
# #
# Glenn Fowler <gsf@research.att.com> #
# #
########################################################################
command=hurl
verbose=0
USAGE=$'
[-?
@(#)$Id: hurl (AT&T Research) 2009-01-20 $
]
[+NAME?hurl - copy http url data]
[+DESCRIPTION?\bhurl\b copies the data for the \bhttp\b \aurl\a operand
to the standard output. The \aurl\a must be of the form
\b[http://]]\b\ahost\a[\b:\b\aport\a]]\b/\b\apath\a. The default
\aport\a is \b80\b.]
[+?\bhurl\b is a shell script that attempts to access the \aurl\a by
these methods:]{
\bbash\b(1).]
[+wget -nv -O - \aurl\a?]
[+lynx -source \aurl\a?]
[+curl -s -L -o - \aurl\a?]
}
[a:authorize?The url authorization user name and password, separated
by \b:\b (one colon character.)]:[user::password]
[s:size?Terminate the data transmission after \abytes\a have been
transferred.]:[bytes]
[v:verbose?Verbose trace.]
url
[+SEE ALSO?\bcurl\b(1), \blynx\b(1), \bwget\b(1)]
'
;;
*) ARGV0=""
USAGE="a:v"
;;
esac
{
OPTIND=0
exit 2
}
s) limit=$OPTARG ;;
v) verbose=1 ;;
esac
done
url=$1
exec 9<&0
while :
;;
;;
esac
*:+([0-9]))
;;
*) port=80
;;
esac
if ! echo "GET $path HTTP/1.0
Host: $host
User-Agent: $agent
${AUTHORIZE}
" >&8
exit 1
fi
{
exit 1
fi
type=Basic
while :
exit 1
fi
Location:)
continue 2
;;
esac
;;
set -- $data
type=$1
shift
eval "$@"
;;
''|?) break
;;
esac
done
200) if (( limit ))
else cat
fi
exit
;;
401) {
if [[ $AUTHORIZE || $type != Basic ]]
then print authorization failed
exit 1
fi
if [[ ! $authorize ]]
then if [[ ! -t 0 ]]
then print authorization failed
exit 1
fi
print -n "Enter user name for $realm: "
print -n "Password: "
trap 'stty echo <&9' 0 1 2 3 15
stty -echo
read password
stty echo
print
trap - 0 1 2 3 15
fi
} <&9 >&2
continue 2
;;
exit 1
;;
esac
} <&8
elif wget ${authorize:+--http-user="${authorize%:*}"} ${password:+--http-passwd="${password##*:}"} -nv -O - $url 2>/dev/null
exit
exit
exit
exit 1
fi
;;
exit 1
;;
esac
done