glenda.party
term% ls -F
term% pwd
$home/manuals/9front/1/hget
term% cat index.txt
HGET(1)                     General Commands Manual                    HGET(1)



NAME
       hget,  hpost, webpaste, urlencode - retrieve, post to a web page corre‐
       sponding to a url

SYNOPSIS
       hget [ -l | -o file ] [ -p body | -P ] [ -r header ] [ -m method ] [ -b
       baseurl ] url

       hpost  [  -l  ]  [  -g  action  |  -p action | -m action ] [ -u ] url [
       name:value | name@file ] ...

       webpaste [ file ]

       urlencode [ -d ] [ file ]

DESCRIPTION
       Hget retrieves the web page specified by the URL url and writes it, ab‐
       sent the -l and -o options, to standard output.

       The url can be a relative path like ../index.html if a absolute baseurl
       was specified with the -b option.

       If url is of type HTTP and the -p or -P options are specified,  then  a
       HTTP  POST  is performed.  With -p the data to be posted is provided by
       the body argument as a string or alternatively with -P read from  stan‐
       dard input.

       The  -l option causes hget and hpost to print the location URL from the
       transaction response instead of retrieving the body data. This is  use‐
       ful  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.

       The -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,  hget  will  fetch
       the missing bytes.

       Option -r sends an arbitrary HTTP header.

       Option -m overrides the HTTP method used for the request.

       Hpost  retrieves the web page specified by the URL url, parses its HTML
       for form data, then prints rc(1) commands to submit the forms with  de‐
       fault field values.  If an action URL is provided with the -g, -p or -m
       flags, then hget is invoked to execute the transaction  submitting  the
       form data.

       The  -g and -p flags set the form method to GET and POST, respectively.
       The -m flag sets the form method to POST  and  its  enctype  to  multi‐
       part/form-data.   In  all cases, the target relative form action URL is
       set to action.

       The -u flag sets the target URL to url.  As the url parameter is always
       required,  the  -u  flag can be omitted when url follows directly after
       the last option if any.

       The remaining arguments of the form name:value are interpreted as  text
       form  field  names  and values to be submitted. An argument of the form
       name@file is interpreted as a file upload, with the information follow‐
       ing the @ symbol treated as the file name.  For multipart/form-data up‐
       loads (see -m flag), the file has to be seekable as file(1) is  invoked
       to determine its mime type.

       Webpaste  uploads  the contents either of its standard input or file to
       the pastebin website http://okturing.com and then prints  a  URL  where
       the contents may be retrieved.

       Urlencode  is  a  helper program to URL encode and decode files. The -d
       flag, instead of encode, decodes URL encoded file. If no file is given,
       standard  input is read. The resulting data is written to standard out‐
       put.

EXAMPLES
       Download a file from the web.

              % hget http://9front.org/img/nix-on.jpg >/tmp/nix-on.jpg

       Retrieve the commands needed to submit a form, which may then be edited
       and sent.

              % hpost http://p.intma.in
              hpost -u http://p.intma.in -p paste.cgi text:

       Manually specify fields to be sent to a given url.

              % hpost -u http://p.intma.in -p paste.cgi text:'test post'

       Upload a file, print the resulting URL

              % hpost -l http://i.intma.in file@/tmp/screen.png | rc

       Upload the output of ns(1) to http://okturing.com

              % ns | webpaste

SOURCE
       /rc/bin/hget
       /rc/bin/hpost
       /rc/bin/webpaste
       /sys/src/cmd/urlencode.c

SEE ALSO
       webfs(4), ftpfs(4), file(1)

DIAGNOSTICS
       Hget,  hpost  and webpaste require webfs(4) service mounted on /mnt/web
       to work.

HISTORY
       Hget first appeared in Plan 9 from Bell Labs. It was rewritten as an rc
       script  for 9front (January, 2012).  Hpost and urlencode first appeared
       in 9front (October, 2012).  Webpaste first appeared in 9front  (Septem‐
       ber, 2013).



                                                                       HGET(1)