Plasma GitLab Archive
Projects Blog Knowledge

Class Http_fs.http_fs


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.

The following access methods are supported (compare with Netfs.stream_fs):

  • path_encoding: Returns the passed path_encoding. Paths are always encoded.
  • path_exclusions: is just 0,0; 47,47
  • nominal_dot_dot is true
  • read: is supported. All files are considered as binary. The `Skip flag works, and is translated to a Range header.
  • write: is supported and translated to PUT. It is assumed that PUT truncates existing files, and creates new files. The `Exclusive flag is not supported and will be rejected.
  • size: this works only if the server includes the Content-length header in responses to HEAD requests.
  • test and test_list: The tests `N, `E, `D, `F, and `S should work. Files are never symlinks. `R is handled like `E, and `X is handled like `X (i.e. it is assumed that all files are readable, and all directories can be entered). The `W test is never successful.
  • remove: is translated to a DELETE request.
  • readdir: works if index pages are generated (see above)
There is no support for rename, symlink, mkdir, rmdir, and copy.

Options:

  • config_pipeline: one can enable further features on the pipeline object (e.g. authentication, proxies)
  • streaming: if true, the read method 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 read or write by including `Streaming in 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).
  • is_error_response: This function is invoked with the current call object as soon as the response header arrives. It looks at the response code, and checks whether the response is successful or not. In the latter case the function returns the exception to raise. This function can be called several times during the execution of an operation. If it is called at a moment where only the response header is available but not the response body it is ensured that it will be called again with the full response later. Defaults to Http_fs.is_error_response.


This web site is published by Informatikbüro Gerd Stolpmann
Powered by Caml