diff options
author | Timo Rothenpieler <timo@rothenpieler.org> | 2013-09-24 17:50:40 +0200 |
---|---|---|
committer | Timo Rothenpieler <timo@rothenpieler.org> | 2013-09-24 18:03:49 +0200 |
commit | 582c588a5afa11affaf9497354e5713acf370753 (patch) | |
tree | ec261b9f2090ba04ab42c1ae61a95dc69c779e70 | |
parent | 4427e7d01252093993bb773ee0aaf075293ca8d4 (diff) | |
download | wgetpaste-582c588a5afa11affaf9497354e5713acf370753.tar.gz |
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..."
-rwxr-xr-x | wgetpaste | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -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 |