diff options
Diffstat (limited to 'testing/http-unwrap')
-rwxr-xr-x | testing/http-unwrap | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/testing/http-unwrap b/testing/http-unwrap index 5c05544..22392d2 100755 --- a/testing/http-unwrap +++ b/testing/http-unwrap @@ -27,18 +27,26 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. -"$@" | ( - OIFS="$IFS"; - IFS=" -"; - read STATUSLINE; - read BLANKLINE; - IFS="$OIFS"; - OKLINE=${STATUSLINE##Status: 200} - if test x"$OKLINE" = x"$STATUSLINE"; then - cat >&2 - exit 1 - else - cat - fi -) +INFILE=$(mktemp -p "$DATADIR") +OUTFILE=$(mktemp -p "$DATADIR") +cleanup () { + rm -f "$OUTFILE" + rm -f "$INFILE" +} +trap cleanup 0 + +cat > "$INFILE" + +if test $(stat -c %s "$INFILE") != "0"; then + wget -q -O- --content-on-error --auth-no-challenge --post-file="$INFILE" "$@" > "$OUTFILE" 2>&1 +else + wget -q -O- --content-on-error --auth-no-challenge "$@" > "$OUTFILE" 2>&1 +fi +RES="$?" +if test "$RES" = "0"; then + cat "$OUTFILE" + exit 0 +else + cat >&2 "$OUTFILE" + exit 1 +fi |