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