Class ChunkContentUtils


  • public final class ChunkContentUtils
    extends Object
    • Method Detail

      • calculateChunkLength

        public static long calculateChunkLength​(long originalContentLength)
        The chunk format is: chunk-size CRLF chunk-data CRLF.
        Parameters:
        originalContentLength - Original Content length.
        Returns:
        the length of this chunk
      • calculateStreamContentLength

        public static long calculateStreamContentLength​(long originalLength,
                                                        long chunkSize)
        Calculates the content length for data that is divided into chunks.
        Parameters:
        originalLength - original content length.
        chunkSize - chunk size
        Returns:
        Content length of the trailer that will be appended at the end.
      • calculateChecksumTrailerLength

        public static long calculateChecksumTrailerLength​(Algorithm algorithm,
                                                          String headerName)
        Calculates the content length for a given algorithm and header name.
        Parameters:
        algorithm - Algorithm used.
        headerName - Header name.
        Returns:
        Content length of the trailer that will be appended at the end.
      • createChecksumTrailer

        public static ByteBuffer createChecksumTrailer​(String computedChecksum,
                                                       String trailerHeader)
        Creates Chunk encoded checksum trailer for a computedChecksum which is in Base64 encoded.
        Parameters:
        computedChecksum - Base64 encoded computed checksum.
        trailerHeader - Header for the checksum data in the trailer.
        Returns:
        Chunk encoded checksum trailer with given header.
      • createChunk

        public static ByteBuffer createChunk​(ByteBuffer chunkData,
                                             boolean isLastByte)
        Creates ChunkEncoded data for an given chunk data.
        Parameters:
        chunkData - chunk data that needs to be converted to chunk encoded format.
        isLastByte - if true then additional CRLF will not be appended.
        Returns:
        Chunk encoded format of a given data.