package http

import (
	
	
	
	
)

// computeMD5Checksum computes base64 md5 checksum of an io.Reader's contents.
// Returns the byte slice of md5 checksum and an error.
func ( io.Reader) ([]byte, error) {
	 := md5.New()
	// copy errors may be assumed to be from the body.
	,  := io.Copy(, )
	if  != nil {
		return nil, fmt.Errorf("failed to read body: %w", )
	}

	// encode the md5 checksum in base64.
	 := .Sum(nil)
	 := make([]byte, base64.StdEncoding.EncodedLen(len()))
	base64.StdEncoding.Encode(, )
	return , nil
}