module Http_fs:sig
..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
.
There is an extension to this class for WebDAV:
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")
The "https" protocol is also supported, so far a TLS provider is
initialized (see Tls
for more information).
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 ]
typeread_file_flag =
[ `Binary | `Dummy | `Header of (string * string) list ]
typewrite_flag =
[ `Binary
| `Create
| `Dummy
| `Exclusive
| `Header of (string * string) list
| `Streaming
| `Truncate ]
typewrite_file_flag =
[ `Binary
| `Create
| `Dummy
| `Exclusive
| `Header of (string * string) list
| `Link
| `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 -> ?enable_ftp:bool -> 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 ->
?enable_ftp:bool -> string -> http_stream_fs