From 582c588a5afa11affaf9497354e5713acf370753 Mon Sep 17 00:00:00 2001 From: Timo Rothenpieler Date: Tue, 24 Sep 2013 17:50:40 +0200 Subject: Add HEADER_$SERVICE variable to pass an additional http header Usefull for example for github gists, where users can do the following in their configuration to paste as their github user: HEADER_gists="Authorization: token 1234abc56789..." --- wgetpaste | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/wgetpaste b/wgetpaste index c5aeb4a..8faf232 100755 --- a/wgetpaste +++ b/wgetpaste @@ -847,12 +847,19 @@ else WGETARGS="--post-data=$(postdata | sed -e 's|$|%0a|g' -e 's|\t|%09|g' | tr -d '\n')" fi + header="HEADER_$SERVICE" + if [[ -n "${!header}" ]]; then + WGETEXTRAHEADER="--header=${!header}" + else + WGETEXTRAHEADER="" + fi + # paste it WGETARGS="--tries=5 --timeout=60 $WGETARGS" if geturl needstdout || [[ $DEBUG || ! -w /dev/null ]]; then - OUTPUT=$(LC_ALL=C wget -O - $WGETARGS $RECIPIENT 2>&1) + OUTPUT=$(LC_ALL=C wget -O - $WGETARGS "$WGETEXTRAHEADER" $RECIPIENT 2>&1) else - OUTPUT=$(LC_ALL=C wget -O /dev/null $WGETARGS $RECIPIENT 2>&1) + OUTPUT=$(LC_ALL=C wget -O /dev/null $WGETARGS "$WGETEXTRAHEADER" $RECIPIENT 2>&1) fi # clean temporary file if it was created -- cgit v1.2.3