diff options
author | cinap_lenrek <cinap_lenrek@gmx.de> | 2012-09-15 07:07:19 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@gmx.de> | 2012-09-15 07:07:19 +0200 |
commit | 9a02104699897c907670b6b65b4fbe3511e368cb (patch) | |
tree | 2e36ce29734cec49caa8dca5ef7406d03ee92ddc | |
parent | cc459aa7ab048282b71999bc61f4fb515e052d4a (diff) | |
download | plan9front-9a02104699897c907670b6b65b4fbe3511e368cb.tar.xz |
hget -P to read postbody from stdin
-rwxr-xr-x | rc/bin/hget | 17 | ||||
-rw-r--r-- | sys/man/1/hget | 14 |
2 files changed, 24 insertions, 7 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} diff --git a/sys/man/1/hget b/sys/man/1/hget index 9e6a4ed3f..daddb1ac6 100644 --- a/sys/man/1/hget +++ b/sys/man/1/hget @@ -9,6 +9,8 @@ hget \- retrieve a web page corresponding to a url ] [ .B -p .I body +| +.B -P ] [ .B -r .I header @@ -42,10 +44,16 @@ If .I url is of type HTTP and the .B -p -option is specified, then an HTTP POST is performed -with +or +.B -P +options are specified, then a HTTP POST is performed. +With +.B -p +the data to be posted is provided by the .I body -as the data to be posted. +argument as a string or alternatively with +.B -P +read from standard input. .PP The .B -o |