Documentation ¶
Overview ¶
Package compositedav provides an http.Handler that composes multiple WebDAV services into a single WebDAV service that presents each of them as its own folder.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Child ¶
type Child struct { *dirfs.Child // BaseURL returns the base URL of the WebDAV service to which we'll proxy // requests for this Child. We will append the filename from the original // URL to this. BaseURL func() (string, error) // Transport (if specified) is the http transport to use when communicating // with this Child's WebDAV service. Transport http.RoundTripper // contains filtered or unexported fields }
Child is a child folder of this compositedav.
func (*Child) CloseIdleConnections ¶
func (c *Child) CloseIdleConnections()
CloseIdleConnections forcibly closes any idle connections on this Child's reverse proxy.
type Handler ¶
type Handler struct { // Logf specifies a logging function to use. Logf logger.Logf // Clock, if specified, determines the current time. If not specified, we // default to time.Now(). Clock tstime.Clock // StatCache is an optional cache for PROPFIND results. StatCache *StatCache // contains filtered or unexported fields }
Handler implements http.Handler by using a dirfs.FS for showing a virtual read-only folder that represents the Child WebDAV services as sub-folders and proxying all requests for resources on the children to those children via httputil.ReverseProxy instances.
func (*Handler) Close ¶
func (h *Handler) Close()
Close closes this Handler,including closing all idle connections on children and stopping the StatCache (if caching is enabled).
func (*Handler) GetChild ¶
GetChild gets the Child identified by name, or nil if no matching child found.
func (*Handler) ServeHTTP ¶
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler.
func (*Handler) SetChildren ¶
SetChildren replaces the entire existing set of children with the given ones. If staticRoot is given, the children will appear with a subfolder bearing named <staticRoot>.
type StatCache ¶
StatCache provides a cache for directory listings and file metadata. Especially when used from the command-line, mapped WebDAV drives can generate repetitive requests for the same file metadata. This cache helps reduce the number of round-trips to the WebDAV server for such requests. This is similar to the DirectoryCacheLifetime setting of Windows' built-in SMB client, see https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-7/ff686200(v=ws.10)
StatCache is built specifically to cache the results of PROPFIND requests, which come back as MultiStatus XML responses. Typical clients will issue two kinds of PROPFIND:
The first kind of PROPFIND is a directory listing performed to depth 1. At this depth, the resulting XML will contain stats for the requested folder as well as for all children of that folder.
The second kind of PROPFIND is a file listing performed to depth 0. At this depth, the resulting XML will contain stats only for the requested file.
In order to avoid round-trips, when a PROPFIND at depth 0 is attempted, and the requested file is not in the cache, StatCache will check to see if the parent folder of that file is cached. If so, StatCache infers the correct MultiStatus for the file according to the following logic:
- If the parent folder is NotFound (404), treat the file itself as NotFound
- If the parent folder's XML doesn't contain the file, treat it as NotFound.
- If the parent folder's XML contains the file, build a MultiStatus for the file based on the parent's XML.
To avoid inconsistencies from the perspective of the client, any operations that modify the filesystem (e.g. PUT, MKDIR, etc.) should call invalidate() to invalidate the cache.