(total int64)
| 23 | } |
| 24 | |
| 25 | func (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 可能是一个数字,也可能是一个星号(*) |
no outgoing calls