PROPFIND can walk through directories, retrieving information about
each file. Unfortunately, the filesystem may deny access to the WebDAV
server for various reasons, such as the file truly not being readable
(e.g. a broken symlink), or because the server does not have permission
to read the file. PROPFIND should ignore these.
The current behaviour of the WebDAV server when encountering such issues
is to immediately stop its walk, and output an http 500. This leads to
poor behaviour with the builtin golang server, since the walk has likely
already written out its status header as part of serving the previously
walked files' properties. The server closes the response, also emitting
an error log.
While the error log is noisy, the closed response is truly an issue: the
xml returned to the client is invalid, which means that the response is
useless. It is not unreasonable to expect that a directory shared using
WebDAV has files which cannot be read for the reasons given above. The
shared directory becomes useless with the current behavior.
Rather than making directories with unreadable files useless, skip over
anything that is bad. A more nuanced solution to this problem could
likely involve indicating that the requested properties have problems,
or buffering the response prior to returning the failure. However, this
change is simple and a move in the right direction.
Fixesgolang/go#16195Fixesgolang/go#43782
Change-Id: I065e4c90f7ef797709e5e81e7318c3eafae6db71
GitHub-Last-Rev: d56917e028
GitHub-Pull-Request: golang/net#91
Reviewed-on: https://go-review.googlesource.com/c/net/+/285752
Reviewed-by: Nigel Tao <nigeltao@golang.org>
Reviewed-by: Nigel Tao (INACTIVE; USE @golang.org INSTEAD) <nigeltao@google.com>
Run-TryBot: Nigel Tao <nigeltao@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Matthew Holt <matthew.holt@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Before this commit it was not possible to override the the ContentType
and ETag properties.
Since these properties aren't directly read from the os.FileInfo
objects returned by the FileSystem it seems reasonable that the user
might have a different policy for computing them.
For instance the underlying FileSystem may already know the
ContentType or want to use an MD5 Hash for the ETag.
This commit introduces two new optional interfaces ETager and
ContentTyper which, when defined on the os.FileInfo objects
returned by the FileSystem methods, allows the user of this library to
override the ETag and ContentType generation.
Fixesgolang/go#22577
Change-Id: Ib42e126db3fcc0a93463e61db85fde59be85cca5
Reviewed-on: https://go-review.googlesource.com/109217
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
http.TimeFormat hard-codes GMT and is documented that:
> TimeFormat is the time format to use when generating times in HTTP
> headers. It is like time.RFC1123 but hard-codes GMT as the time
> zone. The time being formatted must be in UTC for Format to generate
> the correct format.
These two users weren't UTC-ifying the time.Time first.
Fixesgolang/go#25015
Change-Id: I82be01856260e363361137fd9651b1940f439f21
Reviewed-on: https://go-review.googlesource.com/113795
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
The tree's pretty inconsistent about single space vs double space
after a period in documentation. Make it consistently a single space,
per earlier decisions, and changes in go repository. This means
contributors won't be confused by misleading precedence.
This CL was generated with:
perl -i -npe 's,^(\s*// .+[a-z]\.) +([A-Z]),$1 $2,' $(git grep -l -E '^\s*//(.+\.) +([A-Z])')
on top of copyright headers change in https://golang.org/cl/32878.
Follows https://golang.org/cl/20022.
Change-Id: I821e4a300122b4668aa31e12eaa914db615e5369
Reviewed-on: https://go-review.googlesource.com/32879
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Go policy has been single space after periods in comments for some time.
The copyright header template at:
https://golang.org/doc/contribute.html#copyright
also uses a single space.
Make them all consistent.
This CL was generated with:
perl -i -npe 's,^(// Copyright [0-9]+ The Go Authors\.) (All rights reserved\.)$,$1 $2,' $(git grep -l -E '^// Copyright [0-9]+ The Go Authors\. All rights reserved\.$')
Follows https://golang.org/cl/20111.
Change-Id: I66671dddf821f5dc027bc254e0196b3e3a2bdf3b
Reviewed-on: https://go-review.googlesource.com/32878
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Currently there is no way to pass request scoped information from
the handler to the FileSytem interface. This can be important
to pass credentials or timeout parameters to the FileSystem
operations. Pipe context through the request from
http.Request.Context(). With pre-go1.7 use context.Background().
Custom FileSystem implementations will need to change, but it will
only require a new argument in each of the FileSystem methods.
The change will be trivial to update to.
Fixesgolang/go#17658
Change-Id: I7491faf3467ad55db793a68081e074a9b3f9624d
Reviewed-on: https://go-review.googlesource.com/32421
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
The net/http package is now better at HTTP redirects, but that broke
these tests which were trying to test the WebDAV server handler's
behavior for a single roundtrip but were accidentally using the HTTP
client (which does redirects) instead.
Use the http.Transport which only does a single HTTP roundtrip.
Change-Id: I8a0cfe2f841effc2f50c26f90c140e94e256a0ac
Reviewed-on: https://go-review.googlesource.com/32413
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dominik Honnef <dominik@honnef.co>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Displayname WebDAV property should be XML escaped. With current
implementation a file with name '<.txt' would make the XML
invalid.
Fixesgolang/go#17158
Change-Id: Ib3b5376094edc957ed15adf511bd1050ea13d27e
Reviewed-on: https://go-review.googlesource.com/29297
Reviewed-by: Nigel Tao <nigeltao@golang.org>
In particular, the Property and DeadPropsHolder types need to refer to
the standard xml package, not the internal fork, to be usable by other
packages.
Inside the package, the XML marshaling and unmarshaling is still done by
the etc/internal/xml package, and will remain that way until
https://github.com/golang/go/issues/13400 is resolved.
Fixesgolang/go#15128.
Change-Id: Ie7e7927d8b30d97d10b1a4a654d774fdf3e7a1e3
Reviewed-on: https://go-review.googlesource.com/21635
Reviewed-by: Andrew Gerrand <adg@golang.org>
There is no semantic change to this commit. A follow-up commit will
change this package's behavior, but this preparatory commit will make
the follow-up's diff smaller, and less noisy.
Change-Id: I12e356fc1f29d3c4a7c3374aab4a1b1eefe01144
Reviewed-on: https://go-review.googlesource.com/21631
Reviewed-by: Andrew Gerrand <adg@golang.org>
During the Go 1.5 development cycle, this package used to require the
standard library's encoding/xml package from Go 1.5 or later, but
https://go-review.googlesource.com/#/c/12772/ (which was submitted in
July 2015) made an internal fork of encoding/xml, as some
namespace related changes introduced in the Go 1.5 cycle were rolled
back in response to https://github.com/golang/go/issues/11841
Thus, this "go1.4" runtime check is no longer necessary. In the long
term, this package should use the standard library's version, and the
internal fork deleted, once https://github.com/golang/go/issues/13400 is
resolved. We could re-introduce a similar check at that time, although
it could be done at compile time (via a "go1.7" build tag) instead of at
runtime.
Change-Id: I18258443aa3d9b519e23106aedb189f25c35495d
Reviewed-on: https://go-review.googlesource.com/21634
Reviewed-by: Andrew Gerrand <adg@golang.org>
StripPrefix in the webdav package strips prefixes from requests
(including the Destination headers) but cannot handle the paths
in the xml entities responses which are confusing some clients
(e.g. cadaver).
This patch replaces StripPrefix with Prefix in the Handler to
handle prefixes both in the requests and in the xml entities
responses.
Change-Id: I67062e30337b2ae422c82a2f927454f5a8a00e34
Reviewed-on: https://go-review.googlesource.com/13857
Reviewed-by: Nigel Tao <nigeltao@golang.org>
The Go 1.5 version of the standard library's encoding/xml package was
rolled back to the 1.4 behavior. See #11841
Change-Id: I5a5d6636b90b19d59dbcfdc44adf54b4f0b3ccb7
Reviewed-on: https://go-review.googlesource.com/12772
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
The default webDAV client for windows explorer, Mini-Redirector,
apparently can not handle XML elements with a default namespace.
This change modifies the emitted XML so that elements are prefixed with
the D: namespace, defined as as "DAV:" in the multistatus tag.
Fixesgolang/go#11177
Change-Id: Ib323ca312fa10bd5aa6e6c61d90812d066543bac
Reviewed-on: https://go-review.googlesource.com/10942
Reviewed-by: Nigel Tao <nigeltao@golang.org>
This CL aims to provide a reusable XML normalisation mechanism across the
golden XML tests.
Change-Id: I39c957f1af4ce4672add38ea6a38c6a7c5f4f25c
Reviewed-on: https://go-review.googlesource.com/11032
Reviewed-by: Nigel Tao <nigeltao@golang.org>
This CL also makes the golden XML proppatch tests more resilient against
changes in the standard encoding/xml package. lockInfo will be updated
in a follow-up CL.
Change-Id: Ic21a1cec9293db7cdc52aa619b265f8d927fea9e
Reviewed-on: https://go-review.googlesource.com/10827
Reviewed-by: Nigel Tao <nigeltao@golang.org>