2011-03-30 13:49:47 +00:00
|
|
|
.TH HGET 1
|
|
|
|
.SH NAME
|
2013-09-20 15:32:42 +00:00
|
|
|
hget, hpost, webpaste, urlencode \- retrieve, post to a web page corresponding to a url
|
2011-03-30 13:49:47 +00:00
|
|
|
.SH SYNOPSIS
|
|
|
|
.B hget
|
|
|
|
[
|
2012-10-18 12:38:07 +00:00
|
|
|
.B -l
|
|
|
|
|
|
2011-03-30 13:49:47 +00:00
|
|
|
.B -o
|
2012-01-11 15:17:54 +00:00
|
|
|
.I file
|
2011-03-30 13:49:47 +00:00
|
|
|
] [
|
|
|
|
.B -p
|
|
|
|
.I body
|
2012-09-15 05:07:19 +00:00
|
|
|
|
|
|
|
|
.B -P
|
2011-03-30 13:49:47 +00:00
|
|
|
] [
|
|
|
|
.B -r
|
|
|
|
.I header
|
2012-01-11 15:17:54 +00:00
|
|
|
] [
|
|
|
|
.B -m
|
|
|
|
.I method
|
|
|
|
] [
|
|
|
|
.B -b
|
|
|
|
.I baseurl
|
2011-03-30 13:49:47 +00:00
|
|
|
]
|
|
|
|
.I url
|
2012-10-11 21:37:48 +00:00
|
|
|
.PP
|
2012-10-14 04:28:58 +00:00
|
|
|
.B hpost
|
2012-10-11 21:37:48 +00:00
|
|
|
[
|
2012-10-18 12:38:07 +00:00
|
|
|
.B -l
|
|
|
|
] [
|
2012-10-11 21:37:48 +00:00
|
|
|
.B -g
|
|
|
|
.I action
|
2013-01-11 09:00:28 +00:00
|
|
|
|
|
2012-10-11 21:37:48 +00:00
|
|
|
.B -p
|
|
|
|
.I action
|
2013-01-11 09:00:28 +00:00
|
|
|
|
|
2012-10-11 21:37:48 +00:00
|
|
|
.B -m
|
|
|
|
.I action
|
|
|
|
] [
|
2020-12-18 04:26:38 +00:00
|
|
|
.B -r
|
|
|
|
.I header
|
|
|
|
] [
|
2012-10-18 12:38:07 +00:00
|
|
|
.B -u
|
|
|
|
]
|
|
|
|
.I url
|
|
|
|
[
|
2012-10-11 21:37:48 +00:00
|
|
|
.I name:value
|
|
|
|
|
|
2012-10-14 04:28:58 +00:00
|
|
|
.I name@file
|
2012-10-11 21:37:48 +00:00
|
|
|
]
|
|
|
|
.I ...
|
2012-10-18 13:23:40 +00:00
|
|
|
.PP
|
2013-09-20 15:32:42 +00:00
|
|
|
.B webpaste
|
2013-09-20 15:46:25 +00:00
|
|
|
[
|
2013-09-18 19:03:50 +00:00
|
|
|
.I file
|
2013-09-20 15:46:25 +00:00
|
|
|
]
|
2013-09-18 19:03:50 +00:00
|
|
|
.PP
|
2012-10-18 13:23:40 +00:00
|
|
|
.B urlencode
|
|
|
|
[
|
|
|
|
.B -d
|
|
|
|
] [
|
|
|
|
.I file
|
|
|
|
]
|
2011-03-30 13:49:47 +00:00
|
|
|
.SH DESCRIPTION
|
|
|
|
.I Hget
|
|
|
|
retrieves the web page specified by the URL
|
|
|
|
.I url
|
|
|
|
and writes it, absent the
|
2012-10-18 12:38:07 +00:00
|
|
|
.B -l
|
|
|
|
and
|
2011-03-30 13:49:47 +00:00
|
|
|
.B -o
|
2012-10-18 12:38:07 +00:00
|
|
|
options, to standard output.
|
2012-01-11 15:17:54 +00:00
|
|
|
.PP
|
|
|
|
The
|
|
|
|
.I url
|
|
|
|
can be a relative path like
|
|
|
|
.B ../index.html
|
|
|
|
if a absolute
|
|
|
|
.I baseurl
|
|
|
|
was specified with the
|
|
|
|
.B -b
|
|
|
|
option.
|
2011-03-30 13:49:47 +00:00
|
|
|
.PP
|
|
|
|
If
|
|
|
|
.I url
|
|
|
|
is of type HTTP and the
|
|
|
|
.B -p
|
2012-09-15 05:07:19 +00:00
|
|
|
or
|
|
|
|
.B -P
|
|
|
|
options are specified, then a HTTP POST is performed.
|
|
|
|
With
|
|
|
|
.B -p
|
|
|
|
the data to be posted is provided by the
|
2011-03-30 13:49:47 +00:00
|
|
|
.I body
|
2012-09-15 05:07:19 +00:00
|
|
|
argument as a string or alternatively with
|
|
|
|
.B -P
|
|
|
|
read from standard input.
|
2011-03-30 13:49:47 +00:00
|
|
|
.PP
|
|
|
|
The
|
2012-10-18 12:38:07 +00:00
|
|
|
.B -l
|
|
|
|
option causes
|
|
|
|
.I hget
|
|
|
|
and
|
|
|
|
.I hpost
|
2013-08-23 15:27:30 +00:00
|
|
|
to print the location URL from the transaction response
|
2014-04-25 23:47:36 +00:00
|
|
|
instead of retrieving the body data. This is useful
|
2012-10-18 12:38:07 +00:00
|
|
|
for HTTP POST transactions that redirect to a URL containing
|
2013-08-23 15:27:30 +00:00
|
|
|
the posted data so we wont refetch the data we just uploaded
|
2012-10-18 12:38:07 +00:00
|
|
|
to the site.
|
|
|
|
.PP
|
|
|
|
The
|
2011-03-30 13:49:47 +00:00
|
|
|
.B -o
|
|
|
|
option is used to keep a local file in sync with a
|
|
|
|
web page. If the web page has been modified later than the
|
|
|
|
file, it is copied into the file. If the file is up to date
|
|
|
|
but incomplete,
|
|
|
|
.I hget
|
|
|
|
will fetch the missing bytes.
|
|
|
|
.PP
|
|
|
|
Option
|
|
|
|
.B -r
|
|
|
|
sends an arbitrary HTTP
|
|
|
|
.IR header .
|
2020-12-18 04:26:38 +00:00
|
|
|
The
|
|
|
|
.B -r
|
|
|
|
flag can be repeated to send multiple headers.
|
2011-03-30 13:49:47 +00:00
|
|
|
.PP
|
|
|
|
Option
|
2012-01-11 15:17:54 +00:00
|
|
|
.B -m
|
|
|
|
overrides the HTTP method used for the request.
|
2012-10-11 21:37:48 +00:00
|
|
|
.PP
|
2012-10-14 04:28:58 +00:00
|
|
|
.I Hpost
|
2012-10-11 21:37:48 +00:00
|
|
|
retrieves the web page specified by the URL
|
|
|
|
.I url,
|
|
|
|
parses its HTML for form data, then prints
|
2012-10-14 04:28:58 +00:00
|
|
|
.IR rc (1)
|
|
|
|
commands to submit the forms with default field
|
|
|
|
values.
|
|
|
|
If an
|
|
|
|
.I action
|
|
|
|
URL is provided with the
|
|
|
|
.B -g, -p
|
2012-10-11 21:37:48 +00:00
|
|
|
or
|
|
|
|
.B -m
|
2012-10-14 04:28:58 +00:00
|
|
|
flags, then
|
2012-10-11 21:37:48 +00:00
|
|
|
.I hget
|
2012-10-14 04:28:58 +00:00
|
|
|
is invoked to execute the transaction submitting the form data.
|
2012-10-11 21:37:48 +00:00
|
|
|
.PP
|
|
|
|
The
|
|
|
|
.B -g
|
|
|
|
and
|
|
|
|
.B -p
|
2012-10-12 03:06:11 +00:00
|
|
|
flags set the form method to GET and POST, respectively. The
|
2012-10-11 21:37:48 +00:00
|
|
|
.B -m
|
2012-10-14 04:28:58 +00:00
|
|
|
flag sets the form method to POST and its enctype to
|
|
|
|
.B multipart/form-data.
|
2013-01-11 09:26:54 +00:00
|
|
|
In all cases, the target relative form action URL is set to
|
2012-10-11 21:37:48 +00:00
|
|
|
.I action.
|
|
|
|
.PP
|
2012-10-18 12:38:07 +00:00
|
|
|
The
|
|
|
|
.B -u
|
|
|
|
flag sets the target URL to
|
|
|
|
.I url.
|
|
|
|
As the
|
|
|
|
.I url
|
|
|
|
parameter is always required, the
|
|
|
|
.B -u
|
2013-08-23 15:27:30 +00:00
|
|
|
flag can be omitted when
|
2012-10-18 12:38:07 +00:00
|
|
|
.I url
|
|
|
|
follows directly after the last option if any.
|
|
|
|
.PP
|
2012-10-11 21:37:48 +00:00
|
|
|
The remaining arguments of the form
|
|
|
|
.B name:value
|
2012-10-14 04:28:58 +00:00
|
|
|
are interpreted as text form field names and values to be submitted. An
|
2012-10-12 03:06:11 +00:00
|
|
|
argument of the form
|
2012-10-14 04:28:58 +00:00
|
|
|
.B name@file
|
2012-10-11 21:37:48 +00:00
|
|
|
is interpreted as a file upload, with the information following the
|
|
|
|
.B @
|
2013-01-11 09:26:54 +00:00
|
|
|
symbol treated as the file name.
|
2013-01-11 09:00:28 +00:00
|
|
|
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.
|
2012-10-18 13:23:40 +00:00
|
|
|
.PP
|
2013-09-20 15:32:42 +00:00
|
|
|
.I Webpaste
|
2013-09-18 19:03:50 +00:00
|
|
|
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
|
2012-10-18 13:23:40 +00:00
|
|
|
.I Urlencode
|
|
|
|
is a helper program to URL encode and decode files. The
|
|
|
|
.B -d
|
2013-01-11 09:26:54 +00:00
|
|
|
flag, instead of encode, decodes URL encoded file. If no
|
2012-10-18 13:23:40 +00:00
|
|
|
.I file
|
|
|
|
is given, standard input is read. The resulting data
|
|
|
|
is written to standard output.
|
2012-10-11 21:37:48 +00:00
|
|
|
.SH EXAMPLES
|
2012-10-14 04:28:58 +00:00
|
|
|
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
|
2012-10-11 21:37:48 +00:00
|
|
|
edited and sent.
|
|
|
|
.IP
|
|
|
|
.EX
|
2013-01-11 09:00:28 +00:00
|
|
|
% hpost http://p.intma.in
|
2013-09-20 15:39:33 +00:00
|
|
|
hpost -u http://p.intma.in -p paste.cgi text:
|
2012-10-11 21:37:48 +00:00
|
|
|
.EE
|
|
|
|
.PP
|
2012-10-14 04:28:58 +00:00
|
|
|
Manually specify fields to be sent to a given
|
2012-10-11 21:37:48 +00:00
|
|
|
.I url.
|
|
|
|
.IP
|
|
|
|
.EX
|
2013-01-11 09:00:28 +00:00
|
|
|
% hpost -u http://p.intma.in -p paste.cgi text:'test post'
|
2012-10-11 21:37:48 +00:00
|
|
|
.EE
|
2012-10-12 03:06:11 +00:00
|
|
|
.PP
|
2012-10-18 12:38:07 +00:00
|
|
|
Upload a file, print the resulting URL
|
2012-10-12 03:06:11 +00:00
|
|
|
.IP
|
|
|
|
.EX
|
2012-10-18 12:38:07 +00:00
|
|
|
% hpost -l http://i.intma.in file@/tmp/screen.png | rc
|
2012-10-12 03:06:11 +00:00
|
|
|
.EE
|
2013-09-18 19:03:50 +00:00
|
|
|
.PP
|
|
|
|
Upload the output of
|
|
|
|
.IR ns (1)
|
|
|
|
to
|
|
|
|
.B http://okturing.com
|
|
|
|
.IP
|
|
|
|
.EX
|
2013-09-20 15:32:42 +00:00
|
|
|
% ns | webpaste
|
2013-09-18 19:03:50 +00:00
|
|
|
.EE
|
2011-03-30 13:49:47 +00:00
|
|
|
.SH SOURCE
|
2012-01-11 15:17:54 +00:00
|
|
|
.B /rc/bin/hget
|
2012-10-11 21:37:48 +00:00
|
|
|
.br
|
2012-10-14 04:28:58 +00:00
|
|
|
.B /rc/bin/hpost
|
2012-10-18 13:23:40 +00:00
|
|
|
.br
|
2013-09-20 15:32:42 +00:00
|
|
|
.B /rc/bin/webpaste
|
2013-09-18 19:03:50 +00:00
|
|
|
.br
|
2012-10-18 13:23:40 +00:00
|
|
|
.B /sys/src/cmd/urlencode.c
|
2011-03-30 13:49:47 +00:00
|
|
|
.SH "SEE ALSO"
|
2013-01-11 09:00:28 +00:00
|
|
|
.IR webfs (4),
|
|
|
|
.IR ftpfs (4),
|
|
|
|
.IR file (1)
|
2012-01-11 15:17:54 +00:00
|
|
|
.SH DIAGNOSTICS
|
2014-11-12 11:33:14 +00:00
|
|
|
.IR Hget ,
|
2013-01-11 09:00:28 +00:00
|
|
|
.I hpost
|
2013-09-18 19:03:50 +00:00
|
|
|
and
|
2013-09-20 15:32:42 +00:00
|
|
|
.I webpaste
|
2013-01-11 09:00:28 +00:00
|
|
|
require
|
2012-01-11 15:17:54 +00:00
|
|
|
.IR webfs (4)
|
|
|
|
service mounted on
|
|
|
|
.B /mnt/web
|
|
|
|
to work.
|
2013-12-27 21:22:05 +00:00
|
|
|
.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).
|