Package io.micronaut.http.util
Class HttpHeadersUtil
java.lang.Object
io.micronaut.http.util.HttpHeadersUtil
Utility class to work with
HttpHeaders or HTTP Headers.- Since:
- 3.8.0
- Author:
- Sergio del Amo
-
Method Summary
Modifier and TypeMethodDescriptionparseAcceptCharset(@NonNull String acceptCharsetHeaderValue) parseCharacterEncoding(@Nullable MediaType contentType, @NonNull Charset acceptCharset) Resolve theCharsetto use for the request.parseCharacterEncoding(@Nullable String contentTypeHeaderValue, @Nullable String acceptCharsetHeaderValue) Resolve theCharsetto use for request identified by the Content-Type HTTP Header value and the Accept-Charset HTTP Header value.splitAcceptHeader(@NonNull String text) Split an accept-x header and get the first component.static voidtrace(@NonNull org.slf4j.Logger log, @NonNull HttpHeaders httpHeaders) Trace HTTP Headers.static voidtrace(@NonNull org.slf4j.Logger log, @NonNull String name, @NonNull Function<String, List<String>> getAllHeaders) Trace HTTP Headers.static voidtrace(@NonNull org.slf4j.Logger log, @NonNull Supplier<Set<String>> namesSupplier, @NonNull Function<String, List<String>> getAllHeaders) Trace HTTP Headers.static voidtrace(@NonNull org.slf4j.Logger log, @NonNull Set<String> names, @NonNull Function<String, List<String>> getAllHeaders) Trace HTTP Headers.
-
Method Details
-
trace
public static void trace(@NonNull @NonNull org.slf4j.Logger log, @NonNull @NonNull HttpHeaders httpHeaders) Trace HTTP Headers.- Parameters:
log- LoggerhttpHeaders- HTTP Headers
-
trace
public static void trace(@NonNull @NonNull org.slf4j.Logger log, @NonNull @NonNull Set<String> names, @NonNull @NonNull Function<String, List<String>> getAllHeaders) Trace HTTP Headers.- Parameters:
log- Loggernames- HTTP Header namesgetAllHeaders- Function to get all the header values for a particular header name
-
trace
public static void trace(@NonNull @NonNull org.slf4j.Logger log, @NonNull @NonNull Supplier<Set<String>> namesSupplier, @NonNull @NonNull Function<String, List<String>> getAllHeaders) Trace HTTP Headers.- Parameters:
log- LoggernamesSupplier- HTTP Header names ProvidergetAllHeaders- Function to get all the header values for a particular header name
-
trace
public static void trace(@NonNull @NonNull org.slf4j.Logger log, @NonNull @NonNull String name, @NonNull @NonNull Function<String, List<String>> getAllHeaders) Trace HTTP Headers.- Parameters:
log- Loggername- HTTP Header namegetAllHeaders- Function to get all the header values for a particular header name
-
splitAcceptHeader
Split an accept-x header and get the first component. If the header is*, return null.- Parameters:
text- The input header- Returns:
- The first part of the header, or
nullif the header is* - Since:
- 4.0.0
-
parseCharacterEncoding
@NonNull public static @NonNull Charset parseCharacterEncoding(@Nullable @Nullable String contentTypeHeaderValue, @Nullable @Nullable String acceptCharsetHeaderValue) Resolve theCharsetto use for request identified by the Content-Type HTTP Header value and the Accept-Charset HTTP Header value.- Parameters:
contentTypeHeaderValue- Content-Type HTTP Header ValueacceptCharsetHeaderValue- Accept-Charset HTTP Header Value- Returns:
- A
Charset - Since:
- 4.8.8
-
parseCharacterEncoding
@NonNull public static @NonNull Charset parseCharacterEncoding(@Nullable @Nullable MediaType contentType, @NonNull @NonNull Charset acceptCharset) Resolve theCharsetto use for the request. -
parseAcceptCharset
@NonNull public static @NonNull Charset parseAcceptCharset(@NonNull @NonNull String acceptCharsetHeaderValue) - Parameters:
acceptCharsetHeaderValue- Accept-Charset HeaderValue- Returns:
- Accept Charset
- Since:
- 4.8.8
-