Class HttpHeaders
- Since:
- 0.5.0
-
Nested Class Summary
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd the given, single header value under the given name.voidclear()booleancontainsKey(Object key) booleancontainsValue(Object value) entrySet()booleanReturn the list of acceptable media types, as specified by theAcceptheader.Return the list of acceptable charsets, as specified by theAccept-Charsetheader.getAllow()Return the set of allowedHTTP methods, as specified by theAllowheader.Returns the value of theCache-Controlheader.longReturn the length of the body in bytes, as specified by theContent-Lengthheader.Return the media type of the body, as specified by theContent-Typeheader.longgetDate()Returns the date and time at which the message was created, as specified by theDateheader.getETag()Returns the entity tag of the body, as specified by theETagheader.longReturns the date and time at which the message is no longer valid, as specified by theExpiresheader.Return the first header value for the given header name, if any.Returns the value of theIf-None-Matchheader.longReturns the value of theIfModifiedSinceheader.longReturns the time the resource was last changed, as specified by theLast-Modifiedheader.Return the (new) location of a resource, as specified by theLocationheader.Returns the value of theOkta-Request-Idheader.Returns the value of thePragmaheader.inthashCode()booleanisEmpty()keySet()voidstatic HttpHeadersreadOnlyHttpHeaders(HttpHeaders headers) ReturnsHttpHeadersobject that can only be read, not written to.voidSet the given, single header value under the given name.voidSet the list of acceptable media types, as specified by theAcceptheader.voidsetAcceptCharset(List<Charset> acceptableCharsets) Set the list of acceptable charsets, as specified by theAccept-Charsetheader.voidvoidsetAllow(Set<HttpMethod> allowedMethods) Set the set of allowedHTTP methods, as specified by theAllowheader.voidsetCacheControl(String cacheControl) Sets the (new) value of theCache-Controlheader.voidsetContentDispositionFormData(String name, String filename) Sets the (new) value of theContent-Dispositionheader forform-data.voidsetContentLength(long contentLength) Set the length of the body in bytes, as specified by theContent-Lengthheader.voidsetContentType(MediaType mediaType) Set the media type of the body, as specified by theContent-Typeheader.voidsetDate(long date) Sets the date and time at which the message was created, as specified by theDateheader.voidSets the (new) entity tag of the body, as specified by theETagheader.voidsetExpires(long expires) Sets the date and time at which the message is no longer valid, as specified by theExpiresheader.voidsetIfModifiedSince(long ifModifiedSince) Sets the (new) value of theIf-Modified-Sinceheader.voidsetIfNoneMatch(String ifNoneMatch) Sets the (new) value of theIf-None-Matchheader.voidsetIfNoneMatch(List<String> ifNoneMatchList) Sets the (new) values of theIf-None-Matchheader.voidsetLastModified(long lastModified) Sets the time the resource was last changed, as specified by theLast-Modifiedheader.voidsetLocation(URI location) Set the (new) location of a resource, as specified by theLocationheader.voidSets the (new) value of thePragmaheader.intsize()toString()values()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
LINK
- See Also:
-
OKTA_REQUEST_ID
- See Also:
-
OKTA_AGENT
- See Also:
-
OKTA_CLIENT_REQUEST_ID
- See Also:
-
OKTA_USER_AGENT
- See Also:
-
USER_AGENT
- See Also:
-
-
Constructor Details
-
HttpHeaders
public HttpHeaders()Constructs a new, empty instance of theHttpHeadersobject.
-
-
Method Details
-
readOnlyHttpHeaders
ReturnsHttpHeadersobject that can only be read, not written to.- Parameters:
headers- source headers- Returns:
- readonly copy of the source
headers
-
setAccept
Set the list of acceptable media types, as specified by theAcceptheader.- Parameters:
acceptableMediaTypes- the acceptable media types
-
getAccept
Return the list of acceptable media types, as specified by theAcceptheader.Returns an empty list when the acceptable media types are unspecified.
- Returns:
- the acceptable media types
-
setAcceptCharset
Set the list of acceptable charsets, as specified by theAccept-Charsetheader.- Parameters:
acceptableCharsets- the acceptable charsets
-
getAcceptCharset
Return the list of acceptable charsets, as specified by theAccept-Charsetheader.- Returns:
- the acceptable charsets
-
setAllow
Set the set of allowedHTTP methods, as specified by theAllowheader.- Parameters:
allowedMethods- the allowed methods
-
getAllow
Return the set of allowedHTTP methods, as specified by theAllowheader.Returns an empty set when the allowed methods are unspecified.
- Returns:
- the allowed methods
-
setCacheControl
Sets the (new) value of theCache-Controlheader.- Parameters:
cacheControl- the value of the header
-
getCacheControl
Returns the value of theCache-Controlheader.- Returns:
- the value of the header
-
setContentDispositionFormData
Sets the (new) value of theContent-Dispositionheader forform-data.- Parameters:
name- the control namefilename- the filename, may benull
-
setContentLength
public void setContentLength(long contentLength) Set the length of the body in bytes, as specified by theContent-Lengthheader. IfcontentLengthis negative, theContent-Lengthheader will be removed (not set).- Parameters:
contentLength- the content length
-
getContentLength
public long getContentLength()Return the length of the body in bytes, as specified by theContent-Lengthheader.Returns -1 when the content-length is unknown.
- Returns:
- the content length
-
setContentType
Set the media type of the body, as specified by theContent-Typeheader.- Parameters:
mediaType- the media type
-
getContentType
Return the media type of the body, as specified by theContent-Typeheader.Returns
nullwhen the content-type is unknown.- Returns:
- the content type
-
setDate
public void setDate(long date) Sets the date and time at which the message was created, as specified by theDateheader.The date should be specified as the number of milliseconds since January 1, 1970 GMT.
- Parameters:
date- the date
-
getDate
public long getDate()Returns the date and time at which the message was created, as specified by theDateheader.The date is returned as the number of milliseconds since January 1, 1970 GMT. Returns -1 when the date is unknown.
- Returns:
- the creation date/time
- Throws:
IllegalArgumentException- if the value can't be converted to a date
-
setETag
Sets the (new) entity tag of the body, as specified by theETagheader.- Parameters:
eTag- the new entity tag
-
getETag
Returns the entity tag of the body, as specified by theETagheader.- Returns:
- the entity tag
-
setExpires
public void setExpires(long expires) Sets the date and time at which the message is no longer valid, as specified by theExpiresheader.The date should be specified as the number of milliseconds since January 1, 1970 GMT.
- Parameters:
expires- the new expires header value
-
getExpires
public long getExpires()Returns the date and time at which the message is no longer valid, as specified by theExpiresheader.The date is returned as the number of milliseconds since January 1, 1970 GMT. Returns -1 when the date is unknown.
- Returns:
- the expires value
-
setIfModifiedSince
public void setIfModifiedSince(long ifModifiedSince) Sets the (new) value of theIf-Modified-Sinceheader.The date should be specified as the number of milliseconds since January 1, 1970 GMT.
- Parameters:
ifModifiedSince- the new value of the header
-
getIfNotModifiedSince
public long getIfNotModifiedSince()Returns the value of theIfModifiedSinceheader.The date is returned as the number of milliseconds since January 1, 1970 GMT. Returns -1 when the date is unknown.
- Returns:
- the header value
-
setIfNoneMatch
Sets the (new) value of theIf-None-Matchheader.- Parameters:
ifNoneMatch- the new value of the header
-
setIfNoneMatch
Sets the (new) values of theIf-None-Matchheader.- Parameters:
ifNoneMatchList- the new value of the header
-
getIfNoneMatch
Returns the value of theIf-None-Matchheader.- Returns:
- the header value
-
setLastModified
public void setLastModified(long lastModified) Sets the time the resource was last changed, as specified by theLast-Modifiedheader.The date should be specified as the number of milliseconds since January 1, 1970 GMT.
- Parameters:
lastModified- the last modified date
-
getLastModified
public long getLastModified()Returns the time the resource was last changed, as specified by theLast-Modifiedheader.The date is returned as the number of milliseconds since January 1, 1970 GMT. Returns -1 when the date is unknown.
- Returns:
- the last modified date
-
setLocation
Set the (new) location of a resource, as specified by theLocationheader.- Parameters:
location- the location
-
getLocation
Return the (new) location of a resource, as specified by theLocationheader.Returns
nullwhen the location is unknown.- Returns:
- the location
-
setPragma
Sets the (new) value of thePragmaheader.- Parameters:
pragma- the value of the header
-
getPragma
Returns the value of thePragmaheader.- Returns:
- the value of the header
-
getOktaRequestId
Returns the value of theOkta-Request-Idheader.- Returns:
- the value of the header
-
getLinkHeaders
-
getLinkMap
-
getFirst
Return the first header value for the given header name, if any.- Parameters:
headerName- the header name- Returns:
- the first header value; or
null
-
add
Add the given, single header value under the given name.- Parameters:
headerName- the header nameheaderValue- the header value- Throws:
UnsupportedOperationException- if adding headers is not supported- See Also:
-
set
Set the given, single header value under the given name.- Parameters:
headerName- the header nameheaderValue- the header value- Throws:
UnsupportedOperationException- if adding headers is not supported- See Also:
-
setAll
-
toSingleValueMap
-
getXHeaders
-
size
public int size() -
isEmpty
public boolean isEmpty() -
containsKey
- Specified by:
containsKeyin interfaceMap<String,List<String>>
-
containsValue
- Specified by:
containsValuein interfaceMap<String,List<String>>
-
get
-
put
-
remove
-
putAll
-
clear
public void clear() -
keySet
-
values
-
entrySet
-
equals
-
hashCode
public int hashCode() -
toString
-