9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] [PATCH] Update hpost to use -r header like hget
@ 2020-12-15 18:02 Julien Blanchard
  2020-12-15 18:42 ` ori
  2020-12-18  2:25 ` magma698hfsp273p9f
  0 siblings, 2 replies; 15+ messages in thread
From: Julien Blanchard @ 2020-12-15 18:02 UTC (permalink / raw)
  To: 9front

Hello,
This is a small update to hpost which allows the use of a -r header 
option just like in hget. I had the need when trying to push a file to 
an API which also needed an authorization header.
It's the first time I write some not trivial rc script so maybe there is 
a better way to add this option. After quite some testing it looks like 
it works at least :)

Cheers,
julienxx



diff -r ac35c963f8e2 rc/bin/hpost
--- a/rc/bin/hpost	Sun Dec 13 20:23:03 2020 +0100
+++ b/rc/bin/hpost	Tue Dec 15 17:45:26 2020 +0000
@@ -1,12 +1,13 @@
  #!/bin/rc
  rfork e
  url=()
+header=()
  at=()	# text fields
  af=()	# file fields
  l=()

  fn usage {
-	echo 'usage: hpost [ -l ] [ -[gpm] action ] [ -u ] url [ field:value | 
field@file ... ]' >[1=2]
+	echo 'usage: hpost [ -l ] [ -[gpm] action ] [ -r ] header [ -u ] url [ 
field:value | field@file ... ]' >[1=2]
  	exit usage
  }

@@ -14,6 +15,7 @@
  	switch($1){
  	case -l;	l=($l $1)
  	case -u;	shift; url=$1
+	case -r;	shift; header=$1
  	case -g;	shift; action=$1; method=mget
  	case -p;	shift; action=$1; method=mpost
  	case -m;	shift; action=$1; method=multi
@@ -95,7 +97,10 @@
  }

  if(! ~ $action ''){
-	hget=(hget $l)
+	if(~ $header '')
+		hget=(hget $l)
+	if not
+		hget=(hget -r $header $l)
  	$method
  	exit
  }
diff -r ac35c963f8e2 sys/man/1/hget
--- a/sys/man/1/hget	Sun Dec 13 20:23:03 2020 +0100
+++ b/sys/man/1/hget	Tue Dec 15 17:45:26 2020 +0000
@@ -38,6 +38,9 @@
  .B -m
  .I action
  ] [
+.B -r
+.I header
+] [
  .B -u
  ]
  .I url

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2020-12-18  4:38 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-15 18:02 [9front] [PATCH] Update hpost to use -r header like hget Julien Blanchard
2020-12-15 18:42 ` ori
2020-12-16 18:16   ` Julien Blanchard
2020-12-16 18:51     ` sirjofri
2020-12-16 19:50       ` ori
2020-12-16 21:34         ` sirjofri
2020-12-16 21:52           ` ori
2020-12-16 22:55             ` sirjofri
2020-12-16 23:13               ` Steve Simon
2020-12-17  9:33                 ` Julien Blanchard
2020-12-17 10:30                   ` Alex Musolino
2020-12-17 11:23                     ` Julien Blanchard
2020-12-18  4:35                       ` ori
2020-12-16 19:54     ` estevan.cps
2020-12-18  2:25 ` magma698hfsp273p9f

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).