Class TransportFrameUtil

java.lang.Object
io.grpc.internal.TransportFrameUtil

public final class TransportFrameUtil extends 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 final byte[]
     
    private static final Logger
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    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[][]
    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 Details

    • logger

      private static final Logger logger
    • binaryHeaderSuffixBytes

      private static final byte[] binaryHeaderSuffixBytes
  • Constructor Details

    • TransportFrameUtil

      private TransportFrameUtil()
  • Method Details

    • 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.