Allocates enough memory to hold all the contents of the stream. If the allocated memory would be greater than max_size
, returns error.StreamTooLong
. Caller owns returned memory. If this function returns an error, the contents from the stream read so far are lost.