Package com.atlassian.bamboo.web
Class HttpHeaders
java.lang.Object
com.atlassian.bamboo.web.HttpHeaders
- All Implemented Interfaces:
Serializable
,Map<String,
,List<String>> org.springframework.util.MultiValueMap<String,
String>
public class HttpHeaders
extends Object
implements org.springframework.util.MultiValueMap<String,String>, Serializable
Represents HTTP request and response headers, mapping string header names to a list of string values.
- Since:
- 10.0
- See Also:
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionConstruct a new, empty instance of theHttpHeaders
object.HttpHeaders
(org.springframework.util.MultiValueMap<String, String> headers) Construct a newHttpHeaders
instance backed by an existing map. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add the given, single header value under the given name.void
void
void
clear()
boolean
containsKey
(Object key) boolean
containsValue
(Object value) entrySet()
boolean
static String
formatHeaders
(org.springframework.util.MultiValueMap<String, String> headers) Helps to format HTTP header values, as HTTP header values themselves can contain comma-separated values, can become confusing with regularMap
formatting that also uses commas between entries.@Nullable String
Return the first header value for the given header name, if any.getOrEmpty
(Object headerName) Get the list of header values for the given header name, if any.int
hashCode()
boolean
isEmpty()
keySet()
void
void
Set the given, single header value under the given name.void
int
size()
toString()
@NotNull Collection<List<String>>
values()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
Methods inherited from interface org.springframework.util.MultiValueMap
addIfAbsent
-
Constructor Details
-
HttpHeaders
public HttpHeaders()Construct a new, empty instance of theHttpHeaders
object.This is the common constructor, using a case-insensitive map structure.
-
HttpHeaders
Construct a newHttpHeaders
instance backed by an existing map.This constructor is available as an optimization for adapting to existing headers map structures, primarily for internal use within the framework.
- Parameters:
headers
- the headers map (expected to operate with case-insensitive keys)
-
-
Method Details
-
getOrEmpty
Get the list of header values for the given header name, if any.- Parameters:
headerName
- the header name- Returns:
- the list of header values, or an empty list
-
getFirst
Return the first header value for the given header name, if any. -
add
Add the given, single header value under the given name.- Specified by:
add
in interfaceorg.springframework.util.MultiValueMap<String,
String> - Parameters:
headerName
- the header nameheaderValue
- the header value- Throws:
UnsupportedOperationException
- if adding headers is not supported- See Also:
-
addAll
-
addAll
-
set
Set the given, single header value under the given name.- Specified by:
set
in interfaceorg.springframework.util.MultiValueMap<String,
String> - Parameters:
headerName
- the header nameheaderValue
- the header value- Throws:
UnsupportedOperationException
- if adding headers is not supported- See Also:
-
setAll
-
toSingleValueMap
-
size
public int size() -
isEmpty
public boolean isEmpty() -
containsKey
- Specified by:
containsKey
in interfaceMap<String,
List<String>>
-
containsValue
- Specified by:
containsValue
in interfaceMap<String,
List<String>>
-
get
-
put
-
remove
-
putAll
-
clear
public void clear() -
keySet
-
values
-
entrySet
-
equals
-
hashCode
public int hashCode() -
toString
-
formatHeaders
Helps to format HTTP header values, as HTTP header values themselves can contain comma-separated values, can become confusing with regularMap
formatting that also uses commas between entries.- Parameters:
headers
- the headers to format- Returns:
- the headers to a String
-