Package io.grpc.netty

Class GrpcHttp2HeadersUtils.GrpcHttp2InboundHeaders

  • All Implemented Interfaces:
    io.netty.handler.codec.Headers<java.lang.CharSequence,​java.lang.CharSequence,​io.netty.handler.codec.http2.Http2Headers>, io.netty.handler.codec.http2.Http2Headers, java.lang.Iterable<java.util.Map.Entry<java.lang.CharSequence,​java.lang.CharSequence>>
    Direct Known Subclasses:
    GrpcHttp2HeadersUtils.GrpcHttp2RequestHeaders, GrpcHttp2HeadersUtils.GrpcHttp2ResponseHeaders
    Enclosing class:
    GrpcHttp2HeadersUtils

    abstract static class GrpcHttp2HeadersUtils.GrpcHttp2InboundHeaders
    extends AbstractHttp2Headers
    A Http2Headers implementation optimized for inbound/received headers.

    Header names and values are stored in simple arrays, which makes insert run in O(1) and retrievial a O(n). Header name equality is not determined by the equals implementation of CharSequence type, but by comparing two names byte to byte.

    All CharSequence input parameters and return values are required to be of type AsciiString.

    • Field Detail

      • binaryHeaderSuffix

        private static final io.netty.util.AsciiString binaryHeaderSuffix
      • namesAndValues

        private byte[][] namesAndValues
      • values

        private io.netty.util.AsciiString[] values
      • namesAndValuesIdx

        private int namesAndValuesIdx
    • Constructor Detail

      • GrpcHttp2InboundHeaders

        GrpcHttp2InboundHeaders​(int numHeadersGuess)
    • Method Detail

      • add

        protected io.netty.handler.codec.http2.Http2Headers add​(io.netty.util.AsciiString name,
                                                                io.netty.util.AsciiString value)
      • addHeader

        private void addHeader​(io.netty.util.AsciiString value,
                               byte[] nameBytes,
                               byte[] valueBytes)
      • get

        protected java.lang.CharSequence get​(io.netty.util.AsciiString name)
      • contains

        public boolean contains​(java.lang.CharSequence name)
        Specified by:
        contains in interface io.netty.handler.codec.Headers<java.lang.CharSequence,​java.lang.CharSequence,​io.netty.handler.codec.http2.Http2Headers>
        Overrides:
        contains in class AbstractHttp2Headers
      • status

        public java.lang.CharSequence status()
        Specified by:
        status in interface io.netty.handler.codec.http2.Http2Headers
        Overrides:
        status in class AbstractHttp2Headers
      • getAll

        public java.util.List<java.lang.CharSequence> getAll​(java.lang.CharSequence csName)
        Specified by:
        getAll in interface io.netty.handler.codec.Headers<java.lang.CharSequence,​java.lang.CharSequence,​io.netty.handler.codec.http2.Http2Headers>
        Overrides:
        getAll in class AbstractHttp2Headers
      • remove

        @CanIgnoreReturnValue
        public boolean remove​(java.lang.CharSequence csName)
        Specified by:
        remove in interface io.netty.handler.codec.Headers<java.lang.CharSequence,​java.lang.CharSequence,​io.netty.handler.codec.http2.Http2Headers>
        Overrides:
        remove in class AbstractHttp2Headers
      • set

        public io.netty.handler.codec.http2.Http2Headers set​(java.lang.CharSequence name,
                                                             java.lang.CharSequence value)
        Specified by:
        set in interface io.netty.handler.codec.Headers<java.lang.CharSequence,​java.lang.CharSequence,​io.netty.handler.codec.http2.Http2Headers>
        Overrides:
        set in class AbstractHttp2Headers
      • setLong

        public io.netty.handler.codec.http2.Http2Headers setLong​(java.lang.CharSequence name,
                                                                 long value)
        Specified by:
        setLong in interface io.netty.handler.codec.Headers<java.lang.CharSequence,​java.lang.CharSequence,​io.netty.handler.codec.http2.Http2Headers>
        Overrides:
        setLong in class AbstractHttp2Headers
      • namesAndValues

        byte[][] namesAndValues()
        Returns the header names and values as bytes. An even numbered index contains the byte[] representation of a header name (in insertion order), and the subsequent odd index number contains the corresponding header value.

        The values of binary headers (with a -bin suffix), are already base64 decoded.

        The array may contain several null values at the end. A null value an index means that all higher numbered indices also contain null values.

      • numHeaders

        protected int numHeaders()
        Returns the number of none-null headers in namesAndValues().
      • equals

        protected static boolean equals​(io.netty.util.AsciiString str0,
                                        byte[] str1)
      • equals

        protected static boolean equals​(io.netty.util.AsciiString str0,
                                        io.netty.util.AsciiString str1)
      • equals

        protected static boolean equals​(byte[] bytes0,
                                        int offset0,
                                        int length0,
                                        byte[] bytes1,
                                        int offset1,
                                        int length1)
      • bytes

        protected static byte[] bytes​(io.netty.util.AsciiString str)
      • requireAsciiString

        protected static io.netty.util.AsciiString requireAsciiString​(java.lang.CharSequence cs)
      • isPseudoHeader

        protected static boolean isPseudoHeader​(io.netty.util.AsciiString str)
      • validateName

        protected io.netty.util.AsciiString validateName​(io.netty.util.AsciiString str)
      • expandHeadersAndValues

        private void expandHeadersAndValues()
      • size

        public int size()
        Specified by:
        size in interface io.netty.handler.codec.Headers<java.lang.CharSequence,​java.lang.CharSequence,​io.netty.handler.codec.http2.Http2Headers>
        Overrides:
        size in class AbstractHttp2Headers
      • iterator

        public java.util.Iterator<java.util.Map.Entry<java.lang.CharSequence,​java.lang.CharSequence>> iterator()
        Specified by:
        iterator in interface io.netty.handler.codec.Headers<java.lang.CharSequence,​java.lang.CharSequence,​io.netty.handler.codec.http2.Http2Headers>
        Specified by:
        iterator in interface io.netty.handler.codec.http2.Http2Headers
        Specified by:
        iterator in interface java.lang.Iterable<java.util.Map.Entry<java.lang.CharSequence,​java.lang.CharSequence>>
        Overrides:
        iterator in class AbstractHttp2Headers
      • appendNameAndValue

        protected static void appendNameAndValue​(java.lang.StringBuilder builder,
                                                 java.lang.CharSequence name,
                                                 java.lang.CharSequence value,
                                                 boolean prependSeparator)
      • namesAndValuesToImmutableList

        private java.util.List<java.util.Map.Entry<java.lang.CharSequence,​java.lang.CharSequence>> namesAndValuesToImmutableList()
      • namesAndValuesToString

        protected final java.lang.String namesAndValuesToString()