Class HeaderUtils
java.lang.Object
io.servicetalk.encoding.api.internal.HeaderUtils
Header utilities to support encoding.
-
Method Summary
Modifier and TypeMethodDescriptionstatic ContentCodec
encodingFor
(Collection<ContentCodec> allowedList, CharSequence name) Deprecated.static <T> T
encodingForRaw
(List<T> supportedEncoders, Function<T, CharSequence> messageEncodingFunc, CharSequence name) Get the first encoding that matchesname
fromsupportedEncoders
.static ContentCodec
negotiateAcceptedEncoding
(CharSequence acceptEncodingHeaderValue, List<ContentCodec> serverSupportedEncodings) Deprecated.static ContentCodec
negotiateAcceptedEncoding
(List<ContentCodec> clientSupportedEncodings, List<ContentCodec> serverSupportedEncodings) Deprecated.static <T> T
negotiateAcceptedEncodingRaw
(CharSequence acceptEncodingHeaderValue, List<T> supportedEncoders, Function<T, CharSequence> messageEncodingFunc) Get an encoder fromsupportedEncoders
that is acceptable as referenced byacceptEncodingHeaderValue
.
-
Method Details
-
negotiateAcceptedEncoding
@Deprecated @Nullable public static ContentCodec negotiateAcceptedEncoding(@Nullable CharSequence acceptEncodingHeaderValue, List<ContentCodec> serverSupportedEncodings) Deprecated.Establish a commonly accepted encoding between server and client, according to the supported-encodings on the server side and the'Accepted-Encoding'
incoming header on the request.If no supported encodings are configured then the result is always
null
If no accepted encodings are present in the request then the result is alwaysnull
In all other cases, the first matching encoding (that is NOTIdentity.identity()
) is preferred, otherwisenull
is returned.- Parameters:
acceptEncodingHeaderValue
- The accept encoding header value.serverSupportedEncodings
- The server supported codings as configured.- Returns:
- The
ContentCodec
that satisfies both client and server needs, null if none found or matched toIdentity.identity()
-
negotiateAcceptedEncodingRaw
@Nullable public static <T> T negotiateAcceptedEncodingRaw(@Nullable CharSequence acceptEncodingHeaderValue, List<T> supportedEncoders, Function<T, CharSequence> messageEncodingFunc) Get an encoder fromsupportedEncoders
that is acceptable as referenced byacceptEncodingHeaderValue
.- Type Parameters:
T
- The type containing the encoder.- Parameters:
acceptEncodingHeaderValue
- The accept encoding header value.supportedEncoders
- The supported encoders.messageEncodingFunc
- Accessor to get the encoder form an element ofsupportedEncoders
.- Returns:
- an encoder from
supportedEncoders
that is acceptable as referenced byacceptEncodingHeaderValue
.
-
negotiateAcceptedEncoding
@Deprecated @Nullable public static ContentCodec negotiateAcceptedEncoding(List<ContentCodec> clientSupportedEncodings, List<ContentCodec> serverSupportedEncodings) Deprecated.Establish a commonly accepted encoding between server and client, according to the supported-encodings on the server side and the incoming header on the request.If no supported encodings are passed then the result is always
null
Otherwise, the first matching encoding (that is NOTIdentity.identity()
) is preferred, ornull
is returned.- Parameters:
clientSupportedEncodings
- The client supported codings as found in the HTTP header.serverSupportedEncodings
- The server supported codings as configured.- Returns:
- The
ContentCodec
that satisfies both client and server needs, null if none found or matched toIdentity.identity()
-
encodingFor
@Deprecated @Nullable public static ContentCodec encodingFor(Collection<ContentCodec> allowedList, @Nullable CharSequence name) Deprecated.Returns theContentCodec
that matches thename
within theallowedList
. ifname
isnull
or empty it results innull
. Ifname
is'identity'
this will always result inIdentity.identity()
regardless of its presence in theallowedList
.- Parameters:
allowedList
- the source list to find a matching codec from.name
- the codec name used for the equality predicate.- Returns:
- a codec from the allowed-list that name matches the
name
.
-
encodingForRaw
@Nullable public static <T> T encodingForRaw(List<T> supportedEncoders, Function<T, CharSequence> messageEncodingFunc, CharSequence name) Get the first encoding that matchesname
fromsupportedEncoders
.- Type Parameters:
T
- The type containing the encoder.- Parameters:
supportedEncoders
- TheList
of supported encoders.messageEncodingFunc
- A means to access the supported encoding name from an element insupportedEncoders
.name
- The encoding name.- Returns:
- the first encoding that matches
name
fromsupportedEncoders
.
-
encodingForRaw(List, Function, CharSequence)
.