WEBFS(4) WEBFS(4) NAME webfs - world wide web file system SYNOPSIS webfs [ -A useragent ] [ -T timeout ] [ -m mtpt ] [ -s service ] DESCRIPTION Webfs presents a file system interface to the parsing and retrieving of URLs. Webfs mounts itself at mtpt (default /mnt/web), and, if service is specified, will post a service file descriptor in /srv/service. If the environment variable httpproxy is set, all HTTP request initiated by webfs will be made through that proxy url. Webfs presents a three-level file system suggestive of the network protocol hierarchies ip(3) and ether(3). The top level contains the two files: ctl, and clone. The top level ctl file is used to maintain parameters global to the instance of webfs. Reading the ctl file yields the current values of the parameters. Writing strings of the form ``attr value'' sets a particular attribute. The following global parameters can be set: useragent Sets the HTTP user agent string. timeout Sets the request timeout in milliseconds. flushauth url Flushes any associated authentication information for resources under url or all resources if no url was given. preauth url realm Preauthenticates all resources under url with the given realm using HTTP Basic authentication. This will cause webfs to preemptively send the resulting authorization information not waiting for the server to respond with an HTTP 401 Unauthorized status. The top-level directory also contains numbered directories corresponding to connections, which may be used to fetch a single URL. To allocate a connection, open the clone file WEBFS(4) WEBFS(4) and read a number n from it. After opening, the clone file is equivalent to the file n/ctl. A connection is assumed closed once all files in its directory have been closed, and is then will be reallocated. Each connection has a URL attribute url associated with it. This URL may be an absolute URL such as http://www.lucent.com/index.html or a relative URL such as ../index.html. The baseurl attribute sets the URL against which relative URLs are interpreted. Once the URL has been set by writing to the ctl file of the connection, its pieces can be retrieved via individual files in the parsed direc- tory: parsed/url http://pete:email@example.com:8000/cgi/search?q=kittens#results parsed/scheme http parsed/user pete parsed/pass secret parsed/host www.example.com parsed/port 8000 parsed/path /cgi/search parsed/query q=kittens parsed/fragment results If there is associated data to be posted with the request, it can be written to postbody. Opening postbody or body initiates the request. If the request fails, then opening the body or writing to postbody file will fail and return a error string. When the body file has been opened, response headers appear as files in the connection directory. For example reading the contenttype file yields the MIME content type of the body data. If the request was redirected, the URL repre- sented by the parsed directory will change to the final WEBFS(4) WEBFS(4) destination. The resulting data may be read from body as it arrives. The following is a list of attributes that can be set to do a connection prior initiating the request: url,baseurl See above. useragent Sets a custom useragent string to be used with the request. contenttype Sets the MIME content type of the postbody. request Usually, the HTTP method used is POST when postbody file is opend first or GET otherwise. This can be over- ridden with the request attribute so send arbitrary HTTP requests. headers Adds arbitrary HTTP headers to be send with the request. EXAMPLE /rc/bin/hget is a simple client. SOURCE /sys/src/cmd/webfs SEE ALSO webcookies(4), hget(1) DIAGNOSTICS For cookies to work, webcookies(4), should be running and mounted on /mnt/webcookies otherwise cookies will be ignored. HISTORY Webfs first appeared in Plan 9 from Bell Labs. It was rewritten from scratch for 9front (January, 2012).