ref: f6fc570978455ef9b39ad459e0dea31956d9fa5f
parent: 44ddd85077ea0369ccd6337ef30b9909422e3ad5
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Sat Sep 15 03:07:19 EDT 2012
hget -P to read postbody from stdin
--- 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 @@
case -p
p=$2
shift
+ case -P
+ P=1
case -r
r=($r $2)
shift
@@ -43,7 +46,7 @@
}
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 @@
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}--- a/sys/man/1/hget
+++ b/sys/man/1/hget
@@ -9,6 +9,8 @@
] [
.B -p
.I body
+|
+.B -P
] [
.B -r
.I header
@@ -42,10 +44,16 @@
.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
--
⑨