fix: copy tasks using multi-thread downloader can't be canceled (#5028)

#4981 related
This commit is contained in:
Andy Hsu
2023-08-19 14:06:59 +08:00
committed by GitHub
parent ed550594da
commit 1e3950c847
4 changed files with 51 additions and 137 deletions

View File

@ -109,16 +109,11 @@ func ParseRange(s string, size int64) ([]Range, error) { // nolint:gocognit
func (r Range) MimeHeader(contentType string, size int64) textproto.MIMEHeader {
return textproto.MIMEHeader{
"Content-Range": {r.contentRange(size)},
"Content-Range": {r.ContentRange(size)},
"Content-Type": {contentType},
}
}
// for http response header
func (r Range) contentRange(size int64) string {
return fmt.Sprintf("bytes %d-%d/%d", r.Start, r.Start+r.Length-1, size)
}
// ApplyRangeToHttpHeader for http request header
func ApplyRangeToHttpHeader(p Range, headerRef http.Header) http.Header {
header := headerRef