mirror of
https://github.com/AlistGo/alist.git
synced 2025-04-22 21:04:07 +08:00
feat(quark): add preset range header (close #4166)
This commit is contained in:
parent
220fd30830
commit
ecd167d2f9
@ -71,6 +71,9 @@ func (d *Quark) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (
|
||||
"Referer": []string{"https://pan.quark.cn"},
|
||||
"User-Agent": []string{ua},
|
||||
},
|
||||
PresetHeader: http.Header{
|
||||
"Range": []string{"bytes=0-"},
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -17,12 +17,13 @@ type LinkArgs struct {
|
||||
}
|
||||
|
||||
type Link struct {
|
||||
URL string `json:"url"`
|
||||
Header http.Header `json:"header"` // needed header
|
||||
Data io.ReadCloser // return file reader directly
|
||||
Status int // status maybe 200 or 206, etc
|
||||
FilePath *string // local file, return the filepath
|
||||
Expiration *time.Duration // url expiration time
|
||||
URL string `json:"url"`
|
||||
Header http.Header `json:"header"` // needed header
|
||||
PresetHeader http.Header `json:"preset_header"`
|
||||
Data io.ReadCloser // return file reader directly
|
||||
Status int // status maybe 200 or 206, etc
|
||||
FilePath *string // local file, return the filepath
|
||||
Expiration *time.Duration // url expiration time
|
||||
}
|
||||
|
||||
type OtherArgs struct {
|
||||
|
@ -77,12 +77,18 @@ func Proxy(w http.ResponseWriter, r *http.Request, link *model.Link, file model.
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// preset header
|
||||
for h, val := range link.PresetHeader {
|
||||
req.Header[h] = val
|
||||
}
|
||||
// client header
|
||||
for h, val := range r.Header {
|
||||
if utils.SliceContains(conf.SlicesMap[conf.ProxyIgnoreHeaders], strings.ToLower(h)) {
|
||||
continue
|
||||
}
|
||||
req.Header[h] = val
|
||||
}
|
||||
// needed header
|
||||
for h, val := range link.Header {
|
||||
req.Header[h] = val
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user