fix cloudflare, maybe?
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"mime"
|
"mime"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -459,8 +460,21 @@ func (h *Handler) handleGet(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
file.downloadLink = link
|
file.downloadLink = link
|
||||||
if h.cache.StreamWithRclone() {
|
if h.cache.StreamWithRclone() {
|
||||||
// Redirect to the download link
|
redirectURL := file.downloadLink
|
||||||
http.Redirect(w, r, file.downloadLink, http.StatusTemporaryRedirect)
|
|
||||||
|
rangeHeader := r.Header.Get("Range")
|
||||||
|
cacheBuster := fmt.Sprintf("t=%d&r=%s", time.Now().UnixNano(), url.QueryEscape(rangeHeader))
|
||||||
|
|
||||||
|
if strings.Contains(redirectURL, "?") {
|
||||||
|
redirectURL += "&" + cacheBuster
|
||||||
|
} else {
|
||||||
|
redirectURL += "?" + cacheBuster
|
||||||
|
}
|
||||||
|
|
||||||
|
w.Header().Set("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0")
|
||||||
|
w.Header().Set("Pragma", "no-cache")
|
||||||
|
|
||||||
|
http.Redirect(w, r, redirectURL, http.StatusTemporaryRedirect)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user