You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the package golang.org/x/net/webdav there is currently no way to pass request specific parameters from the webdav request to the FileSystem interface. If the FileSystem methods took a context parameter such parameters and request scoped parameters could be put in the context. The context value would come from the http.Request.Context() method when available.
type FileSystem interface {
Mkdir(ctx context.Context, name string, perm os.FileMode) error
OpenFile(ctx context.Context, name string, flag int, perm os.FileMode) (File, error)
RemoveAll(ctx context.Context, name string) error
Rename(ctx context.Context, oldName, newName string) error
Stat(ctx context.Context, name string) (os.FileInfo, error)
}
Examples of where this is useful
Authenticate the username and password from a webdav request and provide file level authentication or remote authentication to the FileSystem.
If a webdav request is initiated but cancelled or the connection is dropped, any subsequent operations, esp remote operations or copy operations on large files, could be also cancelled.
Other Options
I'm not aware of any viable workarounds that would work today that could pass request specific information to the FileSystem operations. The FileSystem interface is provided to the webdav.Handler so there is no way to create some type of closure that returns a request scoped properties. Nor would you want to create an ad-hoc webdav.Handler as that would defeat the lock system.
Compatibility
This would break any custom FileSystem implementations. However updating to be compatible is trivial, just adding a context argument to file methods.
On go1.7+ the context argument would be supplied by http.Request.Context() and on eailier versions the context method would come from golang.org/x/net/context.Background(). When go1.6 support is dropped from the builders the internal xml package and the background context shim can be dropped.
@ribrdb I think that any lock system would use an internal context when a lock request was made based on the characteristics of your locking backend. It wouldn't need to propagate any user information.
If you think it does need the context, open a new issue explaining why.
Proposed Change
In the package
golang.org/x/net/webdav
there is currently no way to pass request specific parameters from the webdav request to the FileSystem interface. If the FileSystem methods took a context parameter such parameters and request scoped parameters could be put in the context. The context value would come from the http.Request.Context() method when available.So this:
would turn into this:
Examples of where this is useful
Other Options
I'm not aware of any viable workarounds that would work today that could pass request specific information to the FileSystem operations. The FileSystem interface is provided to the
webdav.Handler
so there is no way to create some type of closure that returns a request scoped properties. Nor would you want to create an ad-hocwebdav.Handler
as that would defeat the lock system.Compatibility
This would break any custom FileSystem implementations. However updating to be compatible is trivial, just adding a context argument to file methods.
On go1.7+ the context argument would be supplied by http.Request.Context() and on eailier versions the context method would come from
golang.org/x/net/context.Background()
. When go1.6 support is dropped from the builders the internal xml package and the background context shim can be dropped./cc @nigeltao @adg
The text was updated successfully, but these errors were encountered: