MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / Convert

Method Convert

internal/utils/ranges/range.go:25–47  ·  view source on GitHub ↗
(total int64)

Source from the content-addressed store, hash-verified

23}
24
25func (this Range) Convert(total int64) (newRange Range, ok bool) {
26 if total <= 0 {
27 return this, false
28 }
29 if this[0] < 0 {
30 this[0] += total
31 if this[0] < 0 {
32 return this, false
33 }
34 this[1] = total - 1
35 }
36 if this[1] < 0 {
37 this[1] = total - 1
38 }
39 if this[1] > total-1 {
40 this[1] = total - 1
41 }
42 if this[0] > this[1] {
43 return this, false
44 }
45
46 return this, true
47}
48
49// ComposeContentRangeHeader 组合Content-Range Header
50// totalSize 可能是一个数字,也可能是一个星号(*)

Callers 4

TestRange_ConvertFunction · 0.80
doRootMethod · 0.80
doCacheReadMethod · 0.80
tryPartialReaderMethod · 0.80

Calls

no outgoing calls

Tested by 1

TestRange_ConvertFunction · 0.64