Package org.attribyte.api.http
Class Header
java.lang.Object
org.attribyte.api.http.Header
An immutable HTTP request or response header.
- Author:
- Matt Hamer
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe content type header.final StringThe header name.static final Comparator<Header> Compare headers by name.final com.google.common.collect.ImmutableList<String> An immutable list of header values. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns a copy of this header with the new value added.static StringgetCharset(String contentType, String defaultCharset) Gets the charset from a content type header.getName()Gets the name.getValue()Gets the first value.com.google.common.collect.ImmutableList<String> Gets an immutable list of values.String[]Gets all the values.parseParameters(String headerValue) Parses ';' separated parameters in a header value.toString()
-
Field Details
-
CONTENT_TYPE
The content type header.- See Also:
-
nameComparator
Compare headers by name. Safe for use by many threads. -
name
The header name. -
values
An immutable list of header values.
-
-
Constructor Details
-
Header
Creates a single-valued header.- Parameters:
name- The header name.value- The header value.
-
Header
Creates a multi-valued header from an array of values.- Parameters:
name- The header name.values- The header values.
-
Header
Creates a multi-valued header from a collection of values.- Parameters:
name- The header name.values- The header values.
-
-
Method Details
-
addValue
Returns a copy of this header with the new value added.- Parameters:
value- The added value.- Returns:
- The new header.
-
getName
Gets the name.- Returns:
- The name.
-
getValue
Gets the first value.- Returns:
- The value or an empty string if no value.
-
getValues
Gets all the values.- Returns:
- The values or a zero-length array if none.
-
getValueList
Gets an immutable list of values.- Returns:
- The values.
-
parseParameters
Parses ';' separated parameters in a header value.- Parameters:
headerValue- The header value.- Returns:
- A list of parameters.
-
getCharset
Gets the charset from a content type header.- Parameters:
contentType- The content type header value.defaultCharset- The default charset to return if none is specified.- Returns:
- The charset.
-
toString
-