summaryrefslogtreecommitdiff
path: root/rc
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2012-09-15 07:07:19 +0200
committercinap_lenrek <cinap_lenrek@gmx.de>2012-09-15 07:07:19 +0200
commit9a02104699897c907670b6b65b4fbe3511e368cb (patch)
tree2e36ce29734cec49caa8dca5ef7406d03ee92ddc /rc
parentcc459aa7ab048282b71999bc61f4fb515e052d4a (diff)
hget -P to read postbody from stdin
Diffstat (limited to 'rc')
-rwxr-xr-xrc/bin/hget17
1 files changed, 13 insertions, 4 deletions
diff --git a/rc/bin/hget b/rc/bin/hget
index 7b3223223..ca1f183b6 100755
--- a/rc/bin/hget
+++ b/rc/bin/hget
@@ -2,12 +2,13 @@
rfork e
argv0=$0
fn usage {
- echo usage: $argv0 [ -o file ] [ -p body ] [ -r header ] [ -m method ] [ -b baseurl ] url >[1=2]
+ echo 'usage: $argv0 [ -o file ] [ -p body | -P ] [ -r header ] [ -m method ] [ -b baseurl ] url' >[1=2]
exit usage
}
s=0
o=()
p=()
+P=()
r=()
m=()
b=()
@@ -19,6 +20,8 @@ while(~ $1 -*){
case -p
p=$2
shift
+ case -P
+ P=1
case -r
r=($r $2)
shift
@@ -43,7 +46,7 @@ if(! ~ $#o 0){
}
if(! ~ $s 0)
r=($r 'Range: bytes='^$s^'-')
-<>/mnt/web/clone {
+<[3=0] <>/mnt/web/clone {
d=/mnt/web/^`{sed 1q}
if(~ $#b 1)
echo -n baseurl $b >[1=0]
@@ -52,8 +55,14 @@ if(! ~ $s 0)
echo -n headers $i >[1=0]
if(~ $#m 1)
echo -n request $m >[1=0]
- if(! ~ $#p 0)
- echo -n $"p >$d/postbody
+ if(! ~ $#p 0 || ! ~ $#P 0){
+ >$d/postbody {
+ if(! ~ $#p 0)
+ echo -n $"p
+ if(! ~ $#P 0)
+ cat <[0=3]
+ }
+ }
<$d/body {
if(~ $#o 1){
l=`{cat $d/contentlength >[2]/dev/null}