getStreamLength - calculates the length of the overall stream (data + metadata)
(dataLen, chunkSize int64, trailers http.Header)
| 66 | |
| 67 | // getStreamLength - calculates the length of the overall stream (data + metadata) |
| 68 | func getStreamLength(dataLen, chunkSize int64, trailers http.Header) int64 { |
| 69 | if dataLen <= 0 { |
| 70 | return 0 |
| 71 | } |
| 72 | |
| 73 | chunksCount := int64(dataLen / chunkSize) |
| 74 | remainingBytes := int64(dataLen % chunkSize) |
| 75 | streamLen := int64(0) |
| 76 | streamLen += chunksCount * getSignedChunkLength(chunkSize) |
| 77 | if remainingBytes > 0 { |
| 78 | streamLen += getSignedChunkLength(remainingBytes) |
| 79 | } |
| 80 | streamLen += getSignedChunkLength(0) |
| 81 | if len(trailers) > 0 { |
| 82 | for name, placeholder := range trailers { |
| 83 | if len(placeholder) > 0 { |
| 84 | streamLen += int64(len(name) + len(trailerKVSeparator) + len(placeholder[0]) + 1) |
| 85 | } |
| 86 | } |
| 87 | streamLen += int64(len(trailerSignature)+len(trailerKVSeparator)) + signatureStrLen + crlfLen + crlfLen |
| 88 | } |
| 89 | |
| 90 | return streamLen |
| 91 | } |
| 92 | |
| 93 | // buildChunkStringToSignWithService - like buildChunkStringToSign but with configurable service type. |
| 94 | func buildChunkStringToSignWithService(t time.Time, region, previousSig, chunkChecksum, serviceType string) string { |
no test coverage detected