feat(quark): add preset range header (close #4166)

This commit is contained in:
Andy Hsu 2023-04-16 19:26:03 +08:00
parent 220fd30830
commit ecd167d2f9
3 changed files with 16 additions and 6 deletions

View File

@ -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
}

View File

@ -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 {

View File

@ -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
}