Read an HTTP directory:
let fs = new http_fs ~streaming:true "http://localhost/~gerd" let files = fs # readdir  "/"
Download a file into a string:
let ch = fs # read  "/file" let s = Netchannels.string_of_in_obj_channels ch
Copy a file hierarchy to the local disk:
let lfs = Netfs.local_fs() Netfs.copy_into (fs :> Netfs.stream_fs) "/tree" lfs "/tmp"
let fsys = Netglob.of_stream_fs (fs :> Netfs.stream_fs) let files = Netglob.glob ~fsys (`String "/*.gif")
There is the new flag
write, and the
last_response_header for getting the response
header of the most recently executed operation.
Returns the header of the HTTP response of the last operation.
header is set when the last operation returns normally (no
exception was raised). In case of
write, the header is first set when
the stream is closed.
Not_found if the last operation did not receive a header
(or not fully).
Translates a path into a URL
http_fs base_url: Accesses the HTTP file system rooted at
path_encoding: Returns the passed
path_encoding. Paths are always encoded.
path_exclusions: is just
read: is supported. All files are considered as binary. The
`Skipflag works, and is translated to a
write: is supported and translated to
PUT. It is assumed that
PUTtruncates existing files, and creates new files. Note that errors are often first reported when the returned channel is closed!
size: this works only if the server includes the
Content-lengthheader in responses to
test_list: The tests
`Sshould work. Files are never symlinks.
`Ris handled like
`Xis handled like
`X(i.e. it is assumed that all files are readable, and all directories can be entered). The
`Wtest is never successful.
remove: is translated to a
readdir: works if index pages are generated (see above)
There is no support for
config_pipeline: one can enable further features on the pipeline object (e.g. authentication, proxies)
streaming: if true, the
readmethod only reads as much data from the HTTP connection as requested by the user. This assumes that the user does not pause stream accesses for longer periods as this would risk a server timeout. Also, there is no way for the client to automatically reconnect to the HTTP server after crashes. If false (the default), files are first downloaded to a temporary file before they are made accessible as
in_obj_channel. Streaming can also be enabled for each
`Streamingin the list of flags.
tmp_directory: directory for temporary files
tmp_prefix: file prefix for temporary files (w/o directory)
path_encoding: The encoding that is used for the file names. This must match the encoding the server assumes for translating file names to hyperlinks. Unfortunately, there is no way to query the server for this. The default,
`Enc_utf8, seems to be the de-facto standard on the web (e.g. browsers use UTF-8 when non-ASCII characters are entered in the address line).
enable_ftp: This enables anonymous FTP via web proxies. In this case the
base_urlis of the form
ftp://host:port/path. This works only if the pipeline is configured to contact a web proxy understanding FTP URLs.