Bash compiled with --enable-net-redirections
is pretty powerful. (Zsh has similar features.) Heck, I'll even throw HTTP Basic Auth in here, too.
Of course, it's not a very good HTTP/1.1 client; it doesn't support chunked encoding, for example. But that's pretty rare in practice.
read_http() {
local url host path login port
url="${1#http://}"
host="${url%%/*}"
path="${url#${host}}"
login="${host%${host#*@}}"
host="${host#${login}@}"
port="${host#${host%:*}}"
host="${host%:${port}}"
(
exec 3<>"/dev/tcp/${host}/${port:-80}" || exit $?
>&3 echo -n "GET ${path:-/} HTTP/1.1"$'\r\n'
>&3 echo -n "Host: ${host}"$'\r\n'
[[ -n ${login} ]] &&
>&3 echo -n "Authorization: Basic $(uuencode <<<"${login}")"$'\r\n'
>&3 echo -n $'\r\n'
while read line <&3; do
line="${line%$'\r'}"
echo "${line}" >&2
[[ -z ${line} ]] && break
done
dd <&3
)
}
OTOH, if you have Perl's LWP installed, it should ship with a sample binary named GET…