mirror of
https://github.com/1f349/go-webdav.git
synced 2024-12-23 00:34:23 +00:00
internal: add helpers for the Overwrite header
This commit is contained in:
parent
c0a91b0085
commit
d30d4d2932
@ -45,3 +45,23 @@ func (d Depth) String() string {
|
|||||||
}
|
}
|
||||||
panic("webdav: invalid Depth value")
|
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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user