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 TypeMethodDescriptionstatic CharsetparseAcceptCharset(String acceptCharsetHeaderValue) static LocaleparseAcceptLanguage(String text) Resolve the locale of anAccept-Languageheader.static CharsetparseCharacterEncoding(@Nullable MediaType contentType, Charset acceptCharset) Resolve theCharsetto use for the request.static CharsetparseCharacterEncoding(@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.static @Nullable StringsplitAcceptHeader(String text) Split an accept-x header and get the first component.static voidtrace(String loggerName, HttpHeaders httpHeaders) Trace HTTP headers using the named logger and the standard masking policy.static voidtrace(org.slf4j.Logger log, HttpHeaders httpHeaders) Trace HTTP Headers.static voidTrace HTTP Headers.static voidtrace(org.slf4j.Logger log, Supplier<Set<String>> namesSupplier, Function<String, List<String>> getAllHeaders) Trace HTTP Headers.static voidTrace HTTP Headers.
-
Method Details
-
trace
Trace HTTP headers using the named logger and the standard masking policy.- Parameters:
loggerName- Logger namehttpHeaders- HTTP headers- Since:
- 5.2.14
-
trace
Trace HTTP Headers.- Parameters:
log- LoggerhttpHeaders- HTTP Headers
-
trace
-
trace
public static void trace(org.slf4j.Logger log, Supplier<Set<String>> namesSupplier, 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
-
splitAcceptHeader
Split an accept-x header and get the first component. If the header is*or its first component is empty, return null.- Parameters:
text- The input header- Returns:
- The first part of the header, or
nullif the header is*or the first part is empty - Since:
- 4.0.0
-
parseAcceptLanguage
Resolve the locale of anAccept-Languageheader. The default locale is returned if the header is*or its first language tag is longer than the supported maximum. The number of distinct locales is bounded: once many locales the JDK does not provide have been seen, a new one resolves to the closest available locale.- Parameters:
text- The Accept-Language header value- Returns:
- The locale
- Since:
- 5.2.21
-
parseCharacterEncoding
public static Charset 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.- Parameters:
contentTypeHeaderValue- Content-Type HTTP Header ValueacceptCharsetHeaderValue- Accept-Charset HTTP Header Value- Returns:
- A
Charset - Since:
- 4.8.8
-
parseCharacterEncoding
-
parseAcceptCharset
-