]> git.lizzy.rs Git - plan9front.git/blob - sys/man/4/webfs
new webfs, rc based hget
[plan9front.git] / sys / man / 4 / webfs
1 .TH WEBFS 4
2 .SH NAME
3 webfs \- world wide web file system
4 .SH SYNOPSIS
5 .B webfs
6 [
7 .B -m
8 .I mtpt
9 ]
10 [
11 .B -s
12 .I service
13 ]
14 .SH DESCRIPTION
15 .I Webfs
16 presents a file system interface to the parsing and retrieving
17 of URLs.
18 .I Webfs
19 mounts itself at
20 .I mtpt
21 (default
22 .BR /mnt/web ),
23 and, if 
24 .I service
25 is specified, will post a service file descriptor in 
26 .BR /srv/\fIservice .
27 .PP
28 If the enviroment variable
29 .B httpproxy
30 is set, all HTTP request initiated by
31 .I webfs
32 will be made thru that proxy url.
33 .PP
34 .I Webfs
35 presents a three-level file system suggestive
36 of the network protocol hierarchies
37 .IR ip (3)
38 and
39 .IR ether (3).
40 .PP
41 The top level contains the files files:
42 .BR ctl ,
43 and
44 .BR clone .
45 .PP
46 The top level
47 .B ctl
48 file is used to maintain parameters global to the instance of
49 .IR webfs .
50 Reading the 
51 .B ctl
52 file yields the current values of the parameters.
53 Writing strings of the form
54 .RB `` attr " " value ''
55 sets a particular attribute.
56 The top-level directory also contains
57 numbered directories corresponding to connections, which
58 may be used to fetch a single URL.
59 To allocate a connection, open the
60 .B clone
61 file and read a number 
62 .I n
63 from it.
64 After opening, the
65 .B clone
66 file is equivalent to the file
67 .IB n /ctl \fR.
68 A connection is assumed closed once all files in its
69 directory have been closed, and is then will be reallocated.
70 .PP
71 Each connection has a URL attribute
72 .B url
73 associated with it.
74 This URL may be an absolute URL such as
75 .I http://www.lucent.com/index.html
76 or a relative URL such as
77 .IR ../index.html .
78 The
79 .B baseurl
80 attribute sets the URL against which relative URLs
81 are interpreted.
82 Once the URL has been set by wrting to the
83 .B ctl
84 file of the connetcion, its pieces can be retrieved via
85 individual files in the
86 .B parsed
87 directory:
88 .de UU
89 .TP
90 .B parsed/\fI\\$1
91 \\$2
92 ..
93 .UU url http://pete:secret@www.example.com:8000/cgi/search?q=kittens#results
94 .UU scheme http
95 .UU user pete
96 .UU pass secret
97 .UU host www.example.com
98 .UU port 8000
99 .UU path /cgi/search
100 .UU query q=kittens
101 .UU fragment results
102 .PP
103 If there is associated data to be posted with the request,
104 it can be written to
105 .BR postbody .
106 Opening
107 .B postbody
108 or
109 .B body
110 initiates the request. If the request fails,
111 then opening the
112 .B body
113 or writing to
114 .B postbody
115 file will fail and return a error string.
116 .PP
117 When the
118 .B body
119 file has been opend, response headers appear
120 as files in the connection directory. For example
121 reading the
122 .B contenttype
123 file yields the MIME content type of the body data.
124 If the request was redirected, the URL represended
125 by the
126 .B parsed
127 directory will change to the final destination.
128 .PP
129 The resulting data may be read from
130 .B body
131 as it arrives.
132 .PP
133 The following is a list of attributes that can be
134 set to to a connection prior initiating the request:
135 .TP
136 .B url,baseurl
137 See above.
138 .TP
139 .B useragent
140 Sets a custom useragent string to be used with the request.
141 .TP
142 .B contenttype
143 Sets the MIME content type of the postbody.
144 .TP
145 .B request
146 Usualy, the HTTP method used is
147 .B POST
148 when
149 .B postbody
150 file is opend first or
151 .B GET
152 otherwise. This can be overriden with the
153 .B request
154 attribute so send arbitrary HTTP requests.
155 .TP
156 .B headers
157 Adds arbitrary HTTP headers to be send with
158 the request.
159 .SH EXAMPLE
160 .B /rc/bin/hget
161 is a simple client.
162 .SH SOURCE
163 .B /sys/src/cmd/webfs
164 .SH "SEE ALSO"
165 .IR webcookies (4),
166 .IR hget (1)
167 .SH DIAGNOSTICS
168 For cookies to work,
169 .IR webcookies (4),
170 should be running and mounted on
171 .B /mnt/webcookies
172 otherwise cookies will be ignored.