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

Function processPrelude

api-select.go:624–647  ·  view source on GitHub ↗

processPrelude is the function that reads the 12 bytes of the prelude and ensures the CRC is correct while also extracting relevant information into the struct,

(prelude io.Reader, crc hash.Hash32)

Source from the content-addressed store, hash-verified

622// ensures the CRC is correct while also extracting relevant information into
623// the struct,
624func processPrelude(prelude io.Reader, crc hash.Hash32) (preludeInfo, error) {
625 var err error
626 pInfo := preludeInfo{}
627
628 // reads total length of the message (first 4 bytes)
629 pInfo.totalLen, err = extractUint32(prelude)
630 if err != nil {
631 return pInfo, err
632 }
633
634 // reads total header length of the message (2nd 4 bytes)
635 pInfo.headerLen, err = extractUint32(prelude)
636 if err != nil {
637 return pInfo, err
638 }
639
640 // checks that the CRC is correct (3rd 4 bytes)
641 preCRC := crc.Sum32()
642 if err := checkCRC(prelude, preCRC); err != nil {
643 return pInfo, err
644 }
645
646 return pInfo, nil
647}
648
649// extracts the relevant information from the Headers.
650func extractHeader(body io.Reader, myHeaders http.Header) error {

Callers 1

startMethod · 0.85

Calls 2

extractUint32Function · 0.85
checkCRCFunction · 0.85

Tested by

no test coverage detected