module Http_fs:HTTP filesystemsig
..end
Netfs.stream_fs
object, supporting
b
, and the access of a file with path p
is translated to the URL b ^ p
. Note that p
cannot include web
parameters ("?" strings), and hash marks are also not supported.
A directory is recognized by appending a slash to the URL, and checking whether the URL exists.
The contents of a directory are determined by loading the directory URL, analyzing the HTML page, and checking for the presence of hyperlinks that do not contain slashes (or at most a trailing slash). Only hyperlinks of "A" elements are accepted.
Almost every web server can be configured to generate directory
listings that conform to this format. For example, Apache provides
this through the module mod_autoindex
.
An extension to this would be support for WebDAV. This will be
made available shortly as a separate library.
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"
Use globbing:
let fsys = Netglob.of_stream_fs (fs :> Netfs.stream_fs)
let files = Netglob.glob ~fsys (`String "/*.gif")
stream_fs
type`Header
for read
and write
, and the
new method last_response_header
for getting the response
header of the most recently executed operation.typeread_flag =
[ `Binary
| `Dummy
| `Header of (string * string) list
| `Skip of int64
| `Streaming ]
typewrite_flag =
[ `Binary
| `Create
| `Dummy
| `Exclusive
| `Header of (string * string) list
| `Streaming
| `Truncate ]
class type http_stream_fs =object
..end
class http_fs :?config_pipeline:Http_client.pipeline -> unit -> ?streaming:bool -> ?tmp_directory:string -> ?tmp_prefix:string -> ?path_encoding:Netconversion.encoding -> ?enable_read_for_directories:bool -> ?is_error_response:string -> Http_client.http_call -> exn option -> string ->
http_stream_fs
http_fs base_url
: Accesses the HTTP file system rooted at
base_url
.
val http_fs : ?config_pipeline:(Http_client.pipeline -> unit) ->
?streaming:bool ->
?tmp_directory:string ->
?tmp_prefix:string ->
?path_encoding:Netconversion.encoding ->
?enable_read_for_directories:bool ->
?is_error_response:(string -> Http_client.http_call -> exn option) ->
string -> http_stream_fs
val is_error_response : string -> Http_client.http_call -> exn option
status
`Successful
(code in the range
200 to 299) is considered as successful, and:ENOENT
EACCES
EPERM