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