]> git.lizzy.rs Git - plan9front.git/blob - sys/man/1/hget
hget(1): fix minor formatting error
[plan9front.git] / sys / man / 1 / hget
1 .TH HGET 1
2 .SH NAME
3 hget, hpost, webpaste, 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 .B -v
27 ]
28 .I url
29 .PP
30 .B hpost
31 [
32 .B -l
33 ] [
34 .B -g
35 .I action
36 |
37 .B -p
38 .I action
39 |
40 .B -m
41 .I action
42 ] [
43 .B -u
44 ]
45 .I url
46 [
47 .I name:value
48 |
49 .I name@file
50 ]
51 .I ...
52 .PP
53 .B webpaste
54 [
55 .I file
56 ]
57 .PP
58 .B urlencode
59 [
60 .B -d
61 ] [
62 .I file
63 ]
64 .SH DESCRIPTION
65 .I Hget
66 retrieves the web page specified by the URL
67 .I url
68 and writes it, absent the
69 .B -l
70 and
71 .B -o
72 options, to standard output.
73 .PP
74 The
75 .I url
76 can be a relative path like
77 .B ../index.html
78 if a absolute
79 .I baseurl
80 was specified with the
81 .B -b
82 option.
83 .PP
84 If
85 .I url
86 is of type HTTP and the
87 .B -p
88 or
89 .B -P
90 options are specified, then a HTTP POST is performed.
91 With
92 .B -p
93 the data to be posted is provided by the
94 .I body
95 argument as a string or alternatively with
96 .B -P
97 read from standard input.
98 .PP
99 The
100 .B -l
101 option causes
102 .I hget
103 and
104 .I hpost
105 to print the location URL from the transaction response
106 instead of retrieving the the body data. This is useful
107 for HTTP POST transactions that redirect to a URL containing
108 the posted data so we wont refetch the data we just uploaded
109 to the site.
110 .PP
111 The
112 .B -o
113 option is used to keep a local file in sync with a
114 web page.  If the web page has been modified later than the
115 file, it is copied into the file.  If the file is up to date
116 but incomplete,
117 .I hget
118 will fetch the missing bytes.
119 .PP
120 Option
121 .B -r
122 sends an arbitrary HTTP
123 .IR header .
124 .PP
125 Option
126 .B -m
127 overrides the HTTP method used for the request.
128 .PP
129 Option
130 .B -v
131 causes
132 .I hget
133 to emit download status on file descriptor 2,
134 suitable for use with
135 .I aux/statusbar .
136 See EXAMPLES.
137 .PP
138 .I Hpost
139 retrieves the web page specified by the URL
140 .I url,
141 parses its HTML for form data, then prints
142 .IR rc (1)
143 commands to submit the forms with default field
144 values.
145 If an
146 .I action
147 URL is provided with the
148 .B -g, -p
149 or
150 .B -m
151 flags, then
152 .I hget
153 is invoked to execute the transaction submitting the form data.
154 .PP
155 The
156 .B -g
157 and
158 .B -p
159 flags set the form method to GET and POST, respectively. The
160 .B -m
161 flag sets the form method to POST and its enctype to
162 .B multipart/form-data.
163 In all cases, the target relative form action URL is set to
164 .I action.
165 .PP
166 The
167 .B -u
168 flag sets the target URL to
169 .I url.
170 As the
171 .I url
172 parameter is always required, the
173 .B -u
174 flag can be omitted when
175 .I url
176 follows directly after the last option if any.
177 .PP
178 The remaining arguments of the form
179 .B name:value
180 are interpreted as text form field names and values to be submitted. An
181 argument of the form
182 .B name@file
183 is interpreted as a file upload, with the information following the
184 .B @
185 symbol treated as the file name.
186 For
187 .B multipart/form-data
188 uploads (see
189 .B -m
190 flag), the file has to be seekable as
191 .IR file (1)
192 is invoked to determine its mime type.
193 .PP
194 .I Webpaste
195 uploads the contents either of its standard input or
196 .I file
197 to the pastebin website
198 .B http://okturing.com
199 and then prints a URL where the contents may be retrieved.
200 .PP
201 .I Urlencode
202 is a helper program to URL encode and decode files. The
203 .B -d
204 flag, instead of encode, decodes URL encoded file. If no
205 .I file
206 is given, standard input is read. The resulting data
207 is written to standard output.
208 .SH EXAMPLES
209 Download a file from the web.
210 .IP
211 .EX
212 % hget http://9front.org/img/nix-on.jpg >/tmp/nix-on.jpg
213 .EE
214 .PP
215 Use
216 .I hget
217 in conjuncton with
218 .I aux/statusbar
219 to monitor progress.
220 .IP
221 .EX
222 hget -v -o 9front.iso.bz2 \\
223         http://www.r-36.net/9front/9front.iso.bz2 \\
224         |[2] aux/statusbar '9front.iso.bz2'
225 .EE
226 .PP
227 Retrieve the commands needed to submit a form, which may then be
228 edited and sent.
229 .IP
230 .EX
231 % hpost http://p.intma.in
232 hpost -u http://p.intma.in -p paste.cgi text:
233 .EE
234 .PP
235 Manually specify fields to be sent to a given
236 .I url.
237 .IP
238 .EX
239 % hpost -u http://p.intma.in -p paste.cgi text:'test post'
240 .EE
241 .PP
242 Upload a file, print the resulting URL
243 .IP
244 .EX
245 % hpost -l http://i.intma.in file@/tmp/screen.png | rc
246 .EE
247 .PP
248 Upload the output of
249 .IR ns (1)
250 to
251 .B http://okturing.com
252 .IP
253 .EX
254 % ns | webpaste
255 .EE
256 .SH SOURCE
257 .B /rc/bin/hget
258 .br
259 .B /rc/bin/hpost
260 .br
261 .B /rc/bin/webpaste
262 .br
263 .B /sys/src/cmd/urlencode.c
264 .SH "SEE ALSO"
265 .IR webfs (4),
266 .IR ftpfs (4),
267 .IR file (1)
268 .SH DIAGNOSTICS
269 .I Hget ,
270 .I hpost
271 and
272 .I webpaste
273 require
274 .IR webfs (4)
275 service mounted on
276 .B /mnt/web
277 to work.
278 .SH HISTORY
279 .I Hget
280 first appeared in Plan 9 from Bell Labs. It was
281 rewritten as an
282 .I rc
283 script for 9front (January, 2012).
284 .I Hpost
285 and
286 .I urlencode
287 first appeared in 9front (October, 2012).
288 .I Webpaste
289 first appeared in 9front (September, 2013).