Package org.swisspush.gateleen.core.util
Class HttpHeaderUtil
- java.lang.Object
-
- org.swisspush.gateleen.core.util.HttpHeaderUtil
-
public class HttpHeaderUtil extends Object
-
-
Constructor Summary
Constructors Constructor Description HttpHeaderUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends io.vertx.core.MultiMap>
StringgetHeaderValue(T headers, String headerKey)Helper method to find the first occurrence of a http header within the given List of headers.static <T extends io.vertx.core.MultiMap>
booleanhasMatchingHeader(T headers, Pattern headersPattern)Helper method to check the presence of a http header matching the provided pattern.static voidmergeHeaders(io.vertx.core.MultiMap destination, io.vertx.core.MultiMap source, String context)Merges headers, makes sure that only one value of all headers ends up in the destination MultiMap.static <T extends io.vertx.core.MultiMap>
TremoveNonForwardHeaders(T headers)Removes headers which MUST NOT be forwarded by proxies.
-
-
-
Method Detail
-
removeNonForwardHeaders
public static <T extends io.vertx.core.MultiMap> T removeNonForwardHeaders(T headers)
Removes headers which MUST NOT be forwarded by proxies.
- This MAY modifies the passed headers.
- This MAY returns the same (modified) instance as passed.
- Parameters:
headers- The headers to check.- See Also:
- RFC 2616 section 14.10
-
getHeaderValue
@Nullable public static <T extends io.vertx.core.MultiMap> String getHeaderValue(@Nonnull T headers, @Nonnull String headerKey)
Helper method to find the first occurrence of a http header within the given List of headers.- Parameters:
headers- The Map with the header key - value pairs to be evaluatedheaderKey- The key for the header pair we are searching for in the given map. Note that the key searching is non case sensitive.- Returns:
- The found header value or null if none found
-
hasMatchingHeader
public static <T extends io.vertx.core.MultiMap> boolean hasMatchingHeader(@Nonnull T headers, @Nonnull Pattern headersPattern)Helper method to check the presence of a http header matching the provided pattern. Every header entry is checked in the format KEY: VALUE- Parameters:
headers- The Map with the header key - value pairs to be evaluatedheadersPattern- The pattern to match the headers against.- Returns:
- True if a matching header was found, false otherwise
-
mergeHeaders
public static void mergeHeaders(@Nonnull io.vertx.core.MultiMap destination, @Nonnull io.vertx.core.MultiMap source, @Nullable String context)Merges headers, makes sure that only one value of all headers ends up in the destination MultiMap. Note: This is not 100% in line with https://www.rfc-editor.org/rfc/rfc7230#section-3.2.2 to be further looked into.- Parameters:
context- optional context information to be used for logging purposes, not used for the actual merge
-
-