webdav: don't override Referer if user sets it - fixes #6040

This commit is contained in:
Nick Craig-Wood 2022-04-26 08:58:31 +01:00
parent 5605e34f7b
commit 82e24f521f

View File

@ -454,7 +454,9 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e
if err != nil { if err != nil {
return nil, err return nil, err
} }
f.srv.SetHeader("Referer", u.String()) if !f.findHeader(opt.Headers, "Referer") {
f.srv.SetHeader("Referer", u.String())
}
if root != "" && !rootIsDir { if root != "" && !rootIsDir {
// Check to see if the root actually an existing file // Check to see if the root actually an existing file
@ -517,6 +519,17 @@ func (f *Fs) addHeaders(headers fs.CommaSepList) {
} }
} }
// Returns true if the header was configured
func (f *Fs) findHeader(headers fs.CommaSepList, find string) bool {
for i := 0; i < len(headers); i += 2 {
key := f.opt.Headers[i]
if strings.EqualFold(key, find) {
return true
}
}
return false
}
// fetch the bearer token and set it if successful // fetch the bearer token and set it if successful
func (f *Fs) fetchAndSetBearerToken() error { func (f *Fs) fetchAndSetBearerToken() error {
if f.opt.BearerTokenCommand == "" { if f.opt.BearerTokenCommand == "" {