internal: add helpers for the Overwrite header

This commit is contained in:
Simon Ser 2020-01-22 10:09:51 +01:00
parent c0a91b0085
commit d30d4d2932
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48

View File

@ -45,3 +45,23 @@ func (d Depth) String() string {
}
panic("webdav: invalid Depth value")
}
// ParseOverwrite parses an Overwrite header.
func ParseOverwrite(s string) (bool, error) {
switch s {
case "T":
return true, nil
case "F":
return false, nil
}
return false, fmt.Errorf("webdav: invalid Overwrite value")
}
// FormatOverwrite formats an Overwrite header.
func FormatOverwrite(overwrite bool) string {
if overwrite {
return "T"
} else {
return "F"
}
}