Package io.grpc.netty
Class GrpcHttp2HeadersUtils.GrpcHttp2InboundHeaders
java.lang.Object
io.grpc.netty.AbstractHttp2Headers
io.grpc.netty.GrpcHttp2HeadersUtils.GrpcHttp2InboundHeaders
- All Implemented Interfaces:
io.netty.handler.codec.Headers<CharSequence,
,CharSequence, io.netty.handler.codec.http2.Http2Headers> io.netty.handler.codec.http2.Http2Headers
,Iterable<Map.Entry<CharSequence,
CharSequence>>
- Direct Known Subclasses:
GrpcHttp2HeadersUtils.GrpcHttp2RequestHeaders
,GrpcHttp2HeadersUtils.GrpcHttp2ResponseHeaders
- Enclosing class:
GrpcHttp2HeadersUtils
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
.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.handler.codec.http2.Http2Headers
io.netty.handler.codec.http2.Http2Headers.PseudoHeaderName
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final io.netty.util.AsciiString
private byte[][]
private int
private io.netty.util.AsciiString[]
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected io.netty.handler.codec.http2.Http2Headers
add
(io.netty.util.AsciiString name, io.netty.util.AsciiString value) private void
addHeader
(io.netty.util.AsciiString value, byte[] nameBytes, byte[] valueBytes) protected static void
appendNameAndValue
(StringBuilder builder, CharSequence name, CharSequence value, boolean prependSeparator) protected static byte[]
bytes
(io.netty.util.AsciiString str) boolean
contains
(CharSequence name) protected static boolean
equals
(byte[] bytes0, int offset0, int length0, byte[] bytes1, int offset1, int length1) protected static boolean
equals
(io.netty.util.AsciiString str0, byte[] str1) protected static boolean
equals
(io.netty.util.AsciiString str0, io.netty.util.AsciiString str1) private void
protected CharSequence
get
(io.netty.util.AsciiString name) getAll
(CharSequence csName) protected static boolean
isPseudoHeader
(io.netty.util.AsciiString str) iterator()
(package private) byte[][]
Returns the header names and values as bytes.private List
<Map.Entry<CharSequence, CharSequence>> protected final String
protected int
Returns the number of none-null headers innamesAndValues()
.boolean
remove
(CharSequence csName) protected static io.netty.util.AsciiString
io.netty.handler.codec.http2.Http2Headers
set
(CharSequence name, CharSequence value) io.netty.handler.codec.http2.Http2Headers
setLong
(CharSequence name, long value) int
size()
status()
protected io.netty.util.AsciiString
validateName
(io.netty.util.AsciiString str) Methods inherited from class io.grpc.netty.AbstractHttp2Headers
add, add, add, add, addBoolean, addByte, addChar, addDouble, addFloat, addInt, addLong, addObject, addObject, addObject, addShort, addTimeMillis, authority, authority, clear, contains, contains, containsBoolean, containsByte, containsChar, containsDouble, containsFloat, containsInt, containsLong, containsObject, containsShort, containsTimeMillis, get, get, getAllAndRemove, getAndRemove, getAndRemove, getBoolean, getBoolean, getBooleanAndRemove, getBooleanAndRemove, getByte, getByte, getByteAndRemove, getByteAndRemove, getChar, getChar, getCharAndRemove, getCharAndRemove, getDouble, getDouble, getDoubleAndRemove, getDoubleAndRemove, getFloat, getFloat, getFloatAndRemove, getFloatAndRemove, getInt, getInt, getIntAndRemove, getIntAndRemove, getLong, getLong, getLongAndRemove, getLongAndRemove, getShort, getShort, getShortAndRemove, getShortAndRemove, getTimeMillis, getTimeMillis, getTimeMillisAndRemove, getTimeMillisAndRemove, isEmpty, method, method, names, path, path, scheme, scheme, set, set, set, setAll, setBoolean, setByte, setChar, setDouble, setFloat, setInt, setObject, setObject, setObject, setShort, setTimeMillis, status, valueIterator
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
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 Details
-
GrpcHttp2InboundHeaders
GrpcHttp2InboundHeaders(int numHeadersGuess)
-
-
Method Details
-
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
-
contains
- Specified by:
contains
in interfaceio.netty.handler.codec.Headers<CharSequence,
CharSequence, io.netty.handler.codec.http2.Http2Headers> - Overrides:
contains
in classAbstractHttp2Headers
-
status
- Specified by:
status
in interfaceio.netty.handler.codec.http2.Http2Headers
- Overrides:
status
in classAbstractHttp2Headers
-
getAll
- Specified by:
getAll
in interfaceio.netty.handler.codec.Headers<CharSequence,
CharSequence, io.netty.handler.codec.http2.Http2Headers> - Overrides:
getAll
in classAbstractHttp2Headers
-
remove
- Specified by:
remove
in interfaceio.netty.handler.codec.Headers<CharSequence,
CharSequence, io.netty.handler.codec.http2.Http2Headers> - Overrides:
remove
in classAbstractHttp2Headers
-
set
- Specified by:
set
in interfaceio.netty.handler.codec.Headers<CharSequence,
CharSequence, io.netty.handler.codec.http2.Http2Headers> - Overrides:
set
in classAbstractHttp2Headers
-
setLong
- Specified by:
setLong
in interfaceio.netty.handler.codec.Headers<CharSequence,
CharSequence, io.netty.handler.codec.http2.Http2Headers> - Overrides:
setLong
in classAbstractHttp2Headers
-
namesAndValues
byte[][] namesAndValues()Returns the header names and values as bytes. An even numbered index contains thebyte[]
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. Anull
value an index means that all higher numbered indices also containnull
values. -
numHeaders
protected int numHeaders()Returns the number of none-null headers innamesAndValues()
. -
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
-
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 interfaceio.netty.handler.codec.Headers<CharSequence,
CharSequence, io.netty.handler.codec.http2.Http2Headers> - Overrides:
size
in classAbstractHttp2Headers
-
iterator
- Specified by:
iterator
in interfaceio.netty.handler.codec.Headers<CharSequence,
CharSequence, io.netty.handler.codec.http2.Http2Headers> - Specified by:
iterator
in interfaceio.netty.handler.codec.http2.Http2Headers
- Specified by:
iterator
in interfaceIterable<Map.Entry<CharSequence,
CharSequence>> - Overrides:
iterator
in classAbstractHttp2Headers
-
appendNameAndValue
protected static void appendNameAndValue(StringBuilder builder, CharSequence name, CharSequence value, boolean prependSeparator) -
namesAndValuesToImmutableList
-
namesAndValuesToString
-