public final class HeaderUtil extends Object
Modifier and Type | Method and Description |
---|---|
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 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 |
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.
|
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
String
s. 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.Copyright © 2014 ForgeRock AS. All rights reserved.