MCPcopy
hub / github.com/minio/minio-go / getStreamLength

Function getStreamLength

pkg/signer/request-signature-streaming.go:68–91  ·  view source on GitHub ↗

getStreamLength - calculates the length of the overall stream (data + metadata)

(dataLen, chunkSize int64, trailers http.Header)

Source from the content-addressed store, hash-verified

66
67// getStreamLength - calculates the length of the overall stream (data + metadata)
68func 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.
94func buildChunkStringToSignWithService(t time.Time, region, previousSig, chunkChecksum, serviceType string) string {

Callers 1

prepareStreamingRequestFunction · 0.85

Calls 1

getSignedChunkLengthFunction · 0.85

Tested by

no test coverage detected