public class HttpHeaders
extends java.lang.Object
This class mimics the java.net.http.HttpHeaders added in Java 11.
| Modifier and Type | Method and Description |
|---|---|
java.util.List<java.lang.String> |
allValues(java.lang.String name)
Returns an unmodifiable List of all of the header string values of the given named header.
|
protected boolean |
canEqual(java.lang.Object other) |
boolean |
equals(java.lang.Object o) |
java.util.Optional<java.lang.String> |
firstValue(java.lang.String name)
Returns an
Optional containing the first header string value of the given named (and
possibly multi-valued) header. |
int |
hashCode() |
java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
map()
Returns an unmodifiable Map view of this HttpHeaders.
|
static HttpHeaders |
of(java.util.Map<java.lang.String,java.util.List<java.lang.String>> headerMap)
Returns an
HttpHeaders instance initialized from the given map. |
java.lang.String |
toString()
Returns this
HttpHeaders as a string. |
HttpHeaders |
withAdditionalHeader(java.lang.String name,
java.util.List<java.lang.String> values)
Returns a new
HttpHeaders instance containing the headers of the current instance plus
the provided header. |
HttpHeaders |
withAdditionalHeader(java.lang.String name,
java.lang.String value)
Returns a new
HttpHeaders instance containing the headers of the current instance plus
the provided header. |
HttpHeaders |
withAdditionalHeaders(java.util.Map<java.lang.String,java.util.List<java.lang.String>> headerMap)
Returns a new
HttpHeaders instance containing the headers of the current instance plus
the provided headers. |
public static HttpHeaders of(java.util.Map<java.lang.String,java.util.List<java.lang.String>> headerMap)
HttpHeaders instance initialized from the given map.headerMap - the map containing the header names and valuesHttpHeaders instance containing the given headersjava.lang.NullPointerException - if headerMap is nullpublic HttpHeaders withAdditionalHeader(java.lang.String name, java.lang.String value)
HttpHeaders instance containing the headers of the current instance plus
the provided header.name - the name of the header to addvalue - the value of the header to addHttpHeaders instancejava.lang.NullPointerException - if name or value is nullpublic HttpHeaders withAdditionalHeader(java.lang.String name, java.util.List<java.lang.String> values)
HttpHeaders instance containing the headers of the current instance plus
the provided header.name - the name of the header to addvalues - the values of the header to addHttpHeaders instancejava.lang.NullPointerException - if name or values is nullpublic HttpHeaders withAdditionalHeaders(java.util.Map<java.lang.String,java.util.List<java.lang.String>> headerMap)
HttpHeaders instance containing the headers of the current instance plus
the provided headers.headerMap - the map containing the headers to addHttpHeaders instancejava.lang.NullPointerException - if headerMap is nullpublic java.util.List<java.lang.String> allValues(java.lang.String name)
name - the header namepublic java.util.Optional<java.lang.String> firstValue(java.lang.String name)
Optional containing the first header string value of the given named (and
possibly multi-valued) header. If the header is not present, then the returned Optional
is empty.name - the header nameOptional<String> containing the first named header string value, if presentpublic java.util.Map<java.lang.String,java.util.List<java.lang.String>> map()
public java.lang.String toString()
HttpHeaders as a string.toString in class java.lang.Objectpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectprotected boolean canEqual(java.lang.Object other)
public int hashCode()
hashCode in class java.lang.Object