forked from TrueCloudLab/rclone
webdav: Don't accept redirects when reading metadata #2350
Go can't redirect PROPFIND requests properly, it changes the method to GET, so we disable redirects when reading the metadata and assume the object does not exist if we receive a redirect. This is to work-around the qnap redirecting requests for directories without /.
This commit is contained in:
parent
1a65c3a740
commit
1550f70865
1 changed files with 8 additions and 1 deletions
|
@ -182,6 +182,7 @@ func (f *Fs) readMetaDataForPath(path string) (info *api.Prop, err error) {
|
|||
ExtraHeaders: map[string]string{
|
||||
"Depth": "1",
|
||||
},
|
||||
NoRedirect: true,
|
||||
}
|
||||
var result api.Multistatus
|
||||
var resp *http.Response
|
||||
|
@ -191,7 +192,13 @@ func (f *Fs) readMetaDataForPath(path string) (info *api.Prop, err error) {
|
|||
})
|
||||
if apiErr, ok := err.(*api.Error); ok {
|
||||
// does not exist
|
||||
if apiErr.StatusCode == http.StatusNotFound {
|
||||
switch apiErr.StatusCode {
|
||||
case http.StatusNotFound:
|
||||
return nil, fs.ErrorObjectNotFound
|
||||
case http.StatusMovedPermanently, http.StatusFound, http.StatusSeeOther:
|
||||
// Some sort of redirect - go doesn't deal with these properly (it resets
|
||||
// the method to GET). However we can assume that if it was redirected the
|
||||
// object was not found.
|
||||
return nil, fs.ErrorObjectNotFound
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue