package dav
import (
"fmt"
"html"
"path/filepath"
"strings"
)
// optimized versions, no more marshalling
func Directory(path, added string) string {
return fmt.Sprintf(`
%s
%s
HTTP/1.1 200 OK
`, customPathEscape(path), added)
}
func File(path string, fileSize int64, added string) string {
return fmt.Sprintf(`
%s
%d
%s
HTTP/1.1 200 OK
`, customPathEscape(path), fileSize, added)
}
func VidHubDirectory(path, added string) string {
if !strings.HasSuffix(path, "/") {
path += "/"
}
return fmt.Sprintf(`
%s
%s
%s
HTTP/1.1 200 OK
`, customPathEscape(path), html.EscapeString(filepath.Base(path)), added)
}
func VidHubFile(path string, fileSize int64, added string) string {
filename := filepath.Base(path)
return fmt.Sprintf(`
%s
%s
%d
%s
HTTP/1.1 200 OK
`, customPathEscape(path), html.EscapeString(filename), fileSize, added)
}