public final class HeaderUtil extends Object
| Modifier and Type | Method and Description |
|---|---|
static String |
formatDate(Date date)
Formats a
HTTP-date using RFC 1123 format as specified in
RFC 2616. |
static String |
join(Collection<String> values,
char separator)
Joins a collection of header values into a single header value, with a
specified specified separator.
|
static Date |
parseDate(String s)
Parses the supported
HTTP-date formats as specified in
RFC 2616. |
static List<String> |
parseMultiValuedHeader(Message message,
String name)
Parses the named header from the message as a multi-valued comma
separated value.
|
static List<String> |
parseMultiValuedHeader(String header)
Parses the header content as a multi-valued comma separated value.
|
static String[] |
parseParameter(String value)
Splits a single HTTP header parameter name and value from an input string
value.
|
static Map<String,String> |
parseParameters(Collection<String> values)
Parses a set of HTTP header parameters from a collection of values.
|
static String |
parseSingleValuedHeader(Message message,
String name)
Parses the named single-valued header from the message.
|
static String |
quote(String value)
Encloses a string in quotation marks.
|
static List<String> |
split(String value,
char separator)
Parses an HTTP header value, splitting it into multiple values around the
specified separator.
|
static String |
unquote(String value)
Unquotes a string following the logic of
quote(String). |
public static List<String> split(String value, char separator)
Note: This method is liberal in its interpretation of malformed header
values; namely the incorrect use of string and character quoting
mechanisms and unquoted white space. If a null or empty string is
supplied as a value, this method yields an empty list.
value - the header value to be split.separator - the separator character to split headers around.public static String join(Collection<String> values, char separator)
null or empty collection of
header values yeilds a null return value.values - the values to be joined.separator - the separator to separate values within the returned value.public static String[] parseParameter(String value)
split(String, char) method.
This method returns the parameter name-value pair split into an array of
Strings. Element [0] contains the parameter name; element
[1] contains contains the parameter value or null if
there is no value.
A value that is contained within a quoted-string is processed such that the surrounding '"' (quotation mark) characters are removed and single-character quotations hold the character being quoted without the escape '\' (backslash) character. All white space outside of the quoted-string is removed. White space within the quoted-string is retained.
Note: This method is liberal in its interpretation of a malformed header value; namely the incorrect use of string and character quoting mechanisms and unquoted white space.
value - the string to parse the name-value parameter from.String array.public static Map<String,String> parseParameters(Collection<String> values)
split(String, char) method.
A well-formed parameter contains an attribute and optional value,
separated by an '=' (equals sign) character. If the parameter contains no
value, it is represented by a null value in the returned map.
Values that are contained in quoted-strings are processed such that the surrounding '"' (quotation mark) characters are removed and single-character quotations hold the character being quoted without the escape '\' (backslash) character. All white space outside of quoted-strings is removed. White space within quoted-strings is retained.
Note: This method is liberal in its interpretation of malformed header values; namely the incorrect use of string and character quoting mechanisms and unquoted white space.
values - the HTTP header parameters.public static String quote(String value)
value - the value to be enclosed in quotation marks.public static String unquote(String value)
quote(String).value - Value to unquotepublic static List<String> parseMultiValuedHeader(Message message, String name)
split.message - The HTTP request or response.name - The name of the header.public static List<String> parseMultiValuedHeader(String header)
header - The HTTP header content.null or empty.public static String parseSingleValuedHeader(Message message, String name)
message - The HTTP request or response.name - The name of the header.null if the header was not present
in the message.public static String formatDate(Date date)
HTTP-date using RFC 1123 format as specified in
RFC 2616.date - Date to formatHTTP-dateCopyright © 2025 Open Identity Platform Community. All rights reserved.