Class HeaderUtils
- java.lang.Object
-
- io.servicetalk.encoding.api.internal.HeaderUtils
-
public final class HeaderUtils extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ContentCodec
encodingFor(java.util.Collection<ContentCodec> allowedList, java.lang.CharSequence name)
static ContentCodec
negotiateAcceptedEncoding(java.lang.CharSequence acceptEncodingHeaderValue, java.util.List<ContentCodec> serverSupportedEncodings)
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.static ContentCodec
negotiateAcceptedEncoding(java.util.List<ContentCodec> clientSupportedEncodings, java.util.List<ContentCodec> serverSupportedEncodings)
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.
-
-
-
Method Detail
-
negotiateAcceptedEncoding
@Nullable public static ContentCodec negotiateAcceptedEncoding(@Nullable java.lang.CharSequence acceptEncodingHeaderValue, java.util.List<ContentCodec> serverSupportedEncodings)
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 NOTContentCodings.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 toContentCodings.identity()
-
negotiateAcceptedEncoding
@Nullable public static ContentCodec negotiateAcceptedEncoding(java.util.List<ContentCodec> clientSupportedEncodings, java.util.List<ContentCodec> serverSupportedEncodings)
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 NOTContentCodings.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 toContentCodings.identity()
-
encodingFor
@Nullable public static ContentCodec encodingFor(java.util.Collection<ContentCodec> allowedList, @Nullable java.lang.CharSequence name)
Returns theContentCodec
that matches thename
within theallowedList
. ifname
isnull
or empty it results innull
. Ifname
is'identity'
this will always result inContentCodings.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
.
-
-