]> git.lizzy.rs Git - plan9front.git/blob - sys/man/1/hget
hget(1): fix typo, various cleanups
[plan9front.git] / sys / man / 1 / hget
1 .TH HGET 1
2 .SH NAME
3 hget, hpost, urlencode \- retrieve, post to a web page corresponding to a url
4 .SH SYNOPSIS
5 .B hget
6 [
7 .B -l
8 |
9 .B -o
10 .I file
11 ] [
12 .B -p
13 .I body
14 |
15 .B -P
16 ] [
17 .B -r
18 .I header
19 ] [
20 .B -m
21 .I method
22 ] [
23 .B -b
24 .I baseurl
25 ]
26 .I url
27 .PP
28 .B hpost
29 [
30 .B -l
31 ] [
32 .B -g
33 .I action
34 |
35 .B -p
36 .I action
37 |
38 .B -m
39 .I action
40 ] [
41 .B -u
42 ]
43 .I url
44 [
45 .I name:value
46 |
47 .I name@file
48 ]
49 .I ...
50 .PP
51 .B urlencode
52 [
53 .B -d
54 ] [
55 .I file
56 ]
57 .SH DESCRIPTION
58 .I Hget
59 retrieves the web page specified by the URL
60 .I url
61 and writes it, absent the
62 .B -l
63 and
64 .B -o
65 options, to standard output.
66 .PP
67 The
68 .I url
69 can be a relative path like
70 .B ../index.html
71 if a absolute
72 .I baseurl
73 was specified with the
74 .B -b
75 option.
76 .PP
77 If
78 .I url
79 is of type HTTP and the
80 .B -p
81 or
82 .B -P
83 options are specified, then a HTTP POST is performed.
84 With
85 .B -p
86 the data to be posted is provided by the
87 .I body
88 argument as a string or alternatively with
89 .B -P
90 read from standard input.
91 .PP
92 The
93 .B -l
94 option causes
95 .I hget
96 and
97 .I hpost
98 to print the location URL from the transactoin response
99 instead of retriving the the body data. This is usefull
100 for HTTP POST transactions that redirect to a URL containing
101 the prosted data so we wont refetch the data we just uploaded
102 to the site.
103 .PP
104 The
105 .B -o
106 option is used to keep a local file in sync with a
107 web page.  If the web page has been modified later than the
108 file, it is copied into the file.  If the file is up to date
109 but incomplete,
110 .I hget
111 will fetch the missing bytes.
112 .PP
113 Option
114 .B -r
115 sends an arbitrary HTTP
116 .IR header .
117 .PP
118 Option
119 .B -m
120 overrides the HTTP method used for the request.
121 .PP
122 .I Hpost
123 retrieves the web page specified by the URL
124 .I url,
125 parses its HTML for form data, then prints
126 .IR rc (1)
127 commands to submit the forms with default field
128 values.
129 If an
130 .I action
131 URL is provided with the
132 .B -g, -p
133 or
134 .B -m
135 flags, then
136 .I hget
137 is invoked to execute the transaction submitting the form data.
138 .PP
139 The
140 .B -g
141 and
142 .B -p
143 flags set the form method to GET and POST, respectively. The
144 .B -m
145 flag sets the form method to POST and its enctype to
146 .B multipart/form-data.
147 In all cases, the target relative form action URL is set to
148 .I action.
149 .PP
150 The
151 .B -u
152 flag sets the target URL to
153 .I url.
154 As the
155 .I url
156 parameter is always required, the
157 .B -u
158 flag can be omited when
159 .I url
160 follows directly after the last option if any.
161 .PP
162 The remaining arguments of the form
163 .B name:value
164 are interpreted as text form field names and values to be submitted. An
165 argument of the form
166 .B name@file
167 is interpreted as a file upload, with the information following the
168 .B @
169 symbol treated as the file name.
170 For
171 .B multipart/form-data
172 uploads (see
173 .B -m
174 flag), the file has to be seekable as
175 .IR file (1)
176 is invoked to determine its mime type.
177 .PP
178 .I Urlencode
179 is a helper program to URL encode and decode files. The
180 .B -d
181 flag, instead of encode, decodes URL encoded file. If no
182 .I file
183 is given, standard input is read. The resulting data
184 is written to standard output.
185 .SH EXAMPLES
186 Download a file from the web.
187 .IP
188 .EX
189 % hget http://9front.org/img/nix-on.jpg >/tmp/nix-on.jpg
190 .EE
191 .PP
192 Retrieve the commands needed to submit a form, which may then be
193 edited and sent.
194 .IP
195 .EX
196 % hpost http://p.intma.in
197 /bin/hpost -u http://p.intma.in -p paste.cgi text:
198 .EE
199 .PP
200 Manually specify fields to be sent to a given
201 .I url.
202 .IP
203 .EX
204 % hpost -u http://p.intma.in -p paste.cgi text:'test post'
205 .EE
206 .PP
207 Upload a file, print the resulting URL
208 .IP
209 .EX
210 % hpost -l http://i.intma.in file@/tmp/screen.png | rc
211 .EE
212 .SH SOURCE
213 .B /rc/bin/hget
214 .br
215 .B /rc/bin/hpost
216 .br
217 .B /sys/src/cmd/urlencode.c
218 .SH "SEE ALSO"
219 .IR webfs (4),
220 .IR ftpfs (4),
221 .IR file (1)
222 .SH DIAGNOSTICS
223 .I Hget
224 and
225 .I hpost
226 require
227 .IR webfs (4)
228 service mounted on
229 .B /mnt/web
230 to work.