Class HttpHeaders
Object
se.curity.identityserver.sdk.http.HttpHeaders
A read-only view of a set of HTTP headers.
To create a new instance of this class, use the provided HttpHeaders.Builder class.
For convenience, this class provides the build() static method to create an empty
builder, as well as a builder() instance method, which copies the headers
contained in an instance of HttpHeaders into the initial HttpHeaders.Builder's state.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionReturns an unmodifiable List of all of the values of the given named header.static HttpHeaders.Builderbuild()Creates and returns a newBuilder.builder()Create a newHttpHeaders.Builder, setting its initial state with all the headers contained in this instance ofHttpHeaders.firstValue(String name) Returns an optional String containing the first value of the given named (and possibly multi-valued) header.firstValueAsLong(String name) Returns an optional Long containing the first value of the named header field.static HttpHeadersCreate aHttpHeadersinstance based on an external source of header values.static booleanheaderIsCommaSeparated(String name) Returns a boolean for whether the header allows multiple comma separated values.static booleanReturns a boolean for whether the header allows multiple semicolon separated values.map()Returns an unmodifiable multi Map view of this HttpHeaders.singleValueOrError(String name) Returns an optional String containing the single value of the given named header.
-
Field Details
-
MAX_HEADER_VALUES
public static final int MAX_HEADER_VALUES- See Also:
-
-
Method Details
-
headerIsCommaSeparated
Returns a boolean for whether the header allows multiple comma separated values.- Parameters:
name- the name of the header to be asserted for allowing multiple comma separated values.- Returns:
- true or false if the header allows multiple comma separated values
- Since:
- 4.0.0
-
headerIsSemicolonSeparated
Returns a boolean for whether the header allows multiple semicolon separated values.- Parameters:
name- the name of the header to be asserted for allowing multiple semicolon separated values.- Returns:
- true or false if the header allows multiple semicolon separated values
- Since:
- 4.0.0
-
allValues
Returns an unmodifiable List of all of the values of the given named header.- Parameters:
name- the header name- Returns:
- a List of String header values
-
firstValue
Returns an optional String containing the first value of the given named (and possibly multi-valued) header.- Parameters:
name- the header name- Returns:
- the first named value, if it exists
- See Also:
-
firstValueAsLong
Returns an optional Long containing the first value of the named header field. If the header is not present, then the return value is null. If the header is present but contains a value that does not parse as a Long value, then an exception is thrown.- Parameters:
name- the header name- Returns:
- the first named value as a long, if it exists
- Throws:
NumberFormatException- if a value is found, but does not parse as a Long
-
singleValueOrError
Returns an optional String containing the single value of the given named header.This method does not allow multiple values to be provided for this header.
- Parameters:
name- of the header- Returns:
- the value of the header, if it exists and is a single value
- Throws:
MultipleHeadersException- in case more than one value exists for the header
-
map
Returns an unmodifiable multi Map view of this HttpHeaders. This interface should only be used when it is required to iterate over the entire set of headers.All header names are returned using capitalized words.
- Returns:
- the Map of headers
-
builder
Create a newHttpHeaders.Builder, setting its initial state with all the headers contained in this instance ofHttpHeaders.- Returns:
- a new builder with this header contents.
-
from
public static HttpHeaders from(Function<String, List<String>> headerValuesSupplier, Iterable<String> headerNames) Create aHttpHeadersinstance based on an external source of header values.The supplier is used to fetch header values lazily. Once the values of a header are obtained, they are cached internally and will no longer be requested from the supplier.
- Parameters:
headerValuesSupplier- lazy loader of header values. All header names will be requested using capitalized words, eg. Some-Header.headerNames- name of all headers that can be supplied. The names are not case-sensitive.- Returns:
- a HttpHeaders instance backed by the provided supplier of header values.
-
build
Creates and returns a newBuilder.- Returns:
- a builder
-