#!/bin/sh
OUT=""; URL=""; POST=""
while [ $# -gt 0 ]; do
  case "$1" in
    -o|--output) OUT="$2"; shift 2;;
    -sS|-s|-S|-f|-L|-k|--insecure|-O) shift;;
    -X) shift 2;;
    -H|--header) shift 2;;
    -d|--data|--data-raw|--data-binary) POST="$2"; shift 2;;
    --connect-timeout|-m|--max-time) shift 2;;
    --*) shift;;
    http://*|https://*) URL="$1"; shift;;
    *) shift;;
  esac
done
[ -z "$URL" ] && exit 1
if [ -n "$POST" ]; then
  [ -n "$OUT" ] && exec wget -q -O "$OUT" --post-data="$POST" "$URL"
  exec wget -q -O - --post-data="$POST" "$URL"
else
  [ -n "$OUT" ] && exec wget -q -O "$OUT" "$URL"
  exec wget -q -O - "$URL"
fi
