Class TransportFrameUtil


  • public final class TransportFrameUtil
    extends java.lang.Object
    Utility functions for transport layer framing.

    Within a given transport frame we reserve the first byte to indicate the type of compression used for the contents of the transport frame.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static byte[] binaryHeaderSuffixBytes  
      private static java.util.logging.Logger logger  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private TransportFrameUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static boolean endsWith​(byte[] subject, byte[] suffix)
      Returns true if subject ends with suffix.
      private static boolean isSpecCompliantAscii​(byte[] subject)
      Returns true if subject contains only bytes that are spec-compliant ASCII characters and space.
      private static byte[][] serializeHeadersWithCommasInBin​(byte[][] http2Headers, int resumeFrom)  
      static byte[][] toHttp2Headers​(Metadata headers)
      Transform the given headers to a format where only spec-compliant ASCII characters are allowed.
      static byte[][] toRawSerializedHeaders​(byte[][] http2Headers)
      Transform HTTP/2-compliant headers to the raw serialized format which can be deserialized by metadata marshallers.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • logger

        private static final java.util.logging.Logger logger
      • binaryHeaderSuffixBytes

        private static final byte[] binaryHeaderSuffixBytes
    • Constructor Detail

      • TransportFrameUtil

        private TransportFrameUtil()
    • Method Detail

      • toHttp2Headers

        public static byte[][] toHttp2Headers​(Metadata headers)
        Transform the given headers to a format where only spec-compliant ASCII characters are allowed. Binary header values are encoded by Base64 in the result. It is safe to modify the returned array, but not to modify any of the underlying byte arrays.
        Returns:
        the interleaved keys and values.
      • toRawSerializedHeaders

        @CheckReturnValue
        public static byte[][] toRawSerializedHeaders​(byte[][] http2Headers)
        Transform HTTP/2-compliant headers to the raw serialized format which can be deserialized by metadata marshallers. It decodes the Base64-encoded binary headers.

        Warning: This function may partially modify the headers in place by modifying the input array (but not modifying any single byte), so the input reference http2Headers can not be used again.

        Parameters:
        http2Headers - the interleaved keys and values of HTTP/2-compliant headers
        Returns:
        the interleaved keys and values in the raw serialized format
      • serializeHeadersWithCommasInBin

        private static byte[][] serializeHeadersWithCommasInBin​(byte[][] http2Headers,
                                                                int resumeFrom)
      • endsWith

        private static boolean endsWith​(byte[] subject,
                                        byte[] suffix)
        Returns true if subject ends with suffix.
      • isSpecCompliantAscii

        private static boolean isSpecCompliantAscii​(byte[] subject)
        Returns true if subject contains only bytes that are spec-compliant ASCII characters and space.