]> git.lizzy.rs Git - plan9front.git/blobdiff - sys/man/1/hget
vmx: nanosec(): fix non-interruptable temporary, assign fasthz only once after xstart
[plan9front.git] / sys / man / 1 / hget
index 9e6a4ed3fa9c8ab5ac0bd01ed0f5f8aaf3b8576f..c4238344a6a893d72db051e49a2a17e30fc05d8b 100644 (file)
@@ -1,14 +1,18 @@
 .TH HGET 1
 .SH NAME
-hget \- retrieve a web page corresponding to a url
+hget, hpost, webpaste, urlencode \- retrieve, post to a web page corresponding to a url
 .SH SYNOPSIS
 .B hget
 [
+.B -l
+|
 .B -o
 .I file
 ] [
 .B -p
 .I body
+|
+.B -P
 ] [
 .B -r
 .I header
@@ -20,13 +24,50 @@ hget \- retrieve a web page corresponding to a url
 .I baseurl
 ]
 .I url
+.PP
+.B hpost
+[
+.B -l
+] [
+.B -g
+.I action
+|
+.B -p
+.I action
+|
+.B -m
+.I action
+] [
+.B -u
+]
+.I url
+[
+.I name:value
+|
+.I name@file
+]
+.I ...
+.PP
+.B webpaste
+[
+.I file
+]
+.PP
+.B urlencode
+[
+.B -d
+] [
+.I file
+]
 .SH DESCRIPTION
 .I Hget
 retrieves the web page specified by the URL
 .I url
 and writes it, absent the
+.B -l
+and
 .B -o
-option, to standard output.
+options, to standard output.
 .PP
 The
 .I url
@@ -42,10 +83,28 @@ 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 -l
+option causes
+.I hget
+and
+.I hpost
+to print the location URL from the transaction response
+instead of retrieving the body data. This is useful
+for HTTP POST transactions that redirect to a URL containing
+the posted data so we wont refetch the data we just uploaded
+to the site.
 .PP
 The
 .B -o
@@ -64,15 +123,144 @@ sends an arbitrary HTTP
 Option
 .B -m
 overrides the HTTP method used for the request.
+.PP
+.I Hpost
+retrieves the web page specified by the URL
+.I url,
+parses its HTML for form data, then prints
+.IR rc (1)
+commands to submit the forms with default field
+values.
+If an
+.I action
+URL is provided with the
+.B -g, -p
+or
+.B -m
+flags, then
+.I hget
+is invoked to execute the transaction submitting the form data.
+.PP
+The
+.B -g
+and
+.B -p
+flags set the form method to GET and POST, respectively. The
+.B -m
+flag sets the form method to POST and its enctype to
+.B multipart/form-data.
+In all cases, the target relative form action URL is set to
+.I action.
+.PP
+The
+.B -u
+flag sets the target URL to
+.I url.
+As the
+.I url
+parameter is always required, the
+.B -u
+flag can be omitted when
+.I url
+follows directly after the last option if any.
+.PP
+The remaining arguments of the form
+.B name:value
+are interpreted as text form field names and values to be submitted. An
+argument of the form
+.B name@file
+is interpreted as a file upload, with the information following the
+.B @
+symbol treated as the file name.
+For
+.B multipart/form-data
+uploads (see
+.B -m
+flag), the file has to be seekable as
+.IR file (1)
+is invoked to determine its mime type.
+.PP
+.I Webpaste
+uploads the contents either of its standard input or
+.I file
+to the pastebin website
+.B http://okturing.com
+and then prints a URL where the contents may be retrieved.
+.PP
+.I Urlencode
+is a helper program to URL encode and decode files. The
+.B -d
+flag, instead of encode, decodes URL encoded file. If no
+.I file
+is given, standard input is read. The resulting data
+is written to standard output.
+.SH EXAMPLES
+Download a file from the web.
+.IP
+.EX
+% hget http://9front.org/img/nix-on.jpg >/tmp/nix-on.jpg
+.EE
+.PP
+Retrieve the commands needed to submit a form, which may then be
+edited and sent.
+.IP
+.EX
+% hpost http://p.intma.in
+hpost -u http://p.intma.in -p paste.cgi text:
+.EE
+.PP
+Manually specify fields to be sent to a given
+.I url.
+.IP
+.EX
+% hpost -u http://p.intma.in -p paste.cgi text:'test post'
+.EE
+.PP
+Upload a file, print the resulting URL
+.IP
+.EX
+% hpost -l http://i.intma.in file@/tmp/screen.png | rc
+.EE
+.PP
+Upload the output of
+.IR ns (1)
+to
+.B http://okturing.com
+.IP
+.EX
+% ns | webpaste
+.EE
 .SH SOURCE
 .B /rc/bin/hget
+.br
+.B /rc/bin/hpost
+.br
+.B /rc/bin/webpaste
+.br
+.B /sys/src/cmd/urlencode.c
 .SH "SEE ALSO"
 .IR webfs (4),
-.IR ftpfs (4)
+.IR ftpfs (4),
+.IR file (1)
 .SH DIAGNOSTICS
-.I Hget
-requires 
+.IR Hget ,
+.I hpost
+and
+.I webpaste
+require
 .IR webfs (4)
 service mounted on
 .B /mnt/web
 to work.
+.SH HISTORY
+.I Hget
+first appeared in Plan 9 from Bell Labs. It was
+rewritten as an
+.I rc
+script for 9front (January, 2012).
+.I Hpost
+and
+.I urlencode
+first appeared in 9front (October, 2012).
+.I Webpaste
+first appeared in 9front (September, 2013).