feat(webdav): support range get

This commit is contained in:
Xhofe
2022-04-23 22:43:02 +08:00
parent 293d574ce7
commit 27b7dae113
26 changed files with 2268 additions and 22 deletions

View File

@ -28,7 +28,16 @@ func Proxy(w http.ResponseWriter, r *http.Request, link *base.Link, file *model.
w.Header().Set("Content-Type", "application/octet-stream")
w.Header().Set("Content-Disposition", fmt.Sprintf(`attachment; filename=%s`, url.QueryEscape(file.Name)))
w.Header().Set("Content-Length", strconv.FormatInt(file.Size, 10))
w.WriteHeader(http.StatusOK)
if link.Header != nil {
for h, val := range link.Header {
w.Header()[h] = val
}
}
if link.Status == 0 {
w.WriteHeader(http.StatusOK)
} else {
w.WriteHeader(link.Status)
}
_, err = io.Copy(w, link.Data)
if err != nil {
return err

View File

@ -55,7 +55,7 @@ func Proxy(c *gin.Context) {
return
}
// 对于中转不需要重设IP
link, err := driver.Link(base.Args{Path: path}, account)
link, err := driver.Link(base.Args{Path: path, Header: c.Request.Header}, account)
if err != nil {
common.ErrorResp(c, err, 500)
return

View File

@ -133,7 +133,7 @@ func (fs *FileSystem) Link(w http.ResponseWriter, r *http.Request, rawPath strin
if err != nil {
return "", err
}
link_, err := driver.Link(base.Args{Path: path_}, account)
link_, err := driver.Link(base.Args{Path: path_, Header: r.Header}, account)
if err != nil {
return "", err
}