Class HttpHeaders
null is not allowed as a name or value of a header. Names are case-insensitive.
Implementation is not thread-safe.
- Since:
- 1.0
- Author:
- Yaniv Inbar
-
Nested Class Summary
Nested classes/interfaces inherited from class GenericData
GenericData.FlagsNested classes/interfaces inherited from class AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddWarning(String warning) Adds the"Warning"header ornullfor none.clone()Makes a "deep" clone of the generic data, in which the clone is completely independent of the original.final voidfromHttpHeaders(HttpHeaders headers) Puts all headers of theHttpHeadersobject into thisHttpHeadersobject.final voidfromHttpResponse(LowLevelHttpResponse response, StringBuilder logger) Puts all headers of theLowLevelHttpResponseinto thisHttpHeadersobject.final StringReturns the first"Accept"header ornullfor none.final StringReturns the first"Accept-Encoding"header ornullfor none.final LonggetAge()Returns the first"Age"header ornullfor none.final StringReturns the first"WWW-Authenticate"header ornullfor none.Returns all"WWW-Authenticate"headers ornullfor none.final StringReturns the first"Authorization"header ornullfor none.Returns all"Authorization"headers ornullfor none.final StringReturns the first"Cache-Control"header ornullfor none.final StringReturns the first"Content-Encoding"header ornullfor none.final LongReturns the first"Content-Length"header ornullfor none.final StringReturns the first"Content-MD5"header ornullfor none.final StringReturns the first"Content-Range"header ornullfor none.final StringReturns the first"Content-Type"header ornullfor none.final StringReturns the first"Cookie"header ornullfor none.final StringgetDate()Returns the first"Date"header ornullfor none.final StringgetETag()Returns the first"ETag"header ornullfor none.final StringReturns the first"Expires"header ornullfor none.Returns the first header string value for the given header name.getHeaderStringValues(String name) Returns an unmodifiable list of the header string values for the given header name.final StringReturns the first"If-Match"header ornullfor none.final StringReturns the first"If-Modified-Since"header ornullfor none.final StringReturns the first"If-None-Match"header ornullfor none.final StringReturns the first"If-Range"header ornullfor none.final StringReturns the first"If-Unmodified-Since"header ornullfor none.final StringReturns the first"Last-Modified"header ornullfor none.final StringReturns the first"Location"header ornullfor none.final StringReturns the first"MIME-Version"header ornullfor none.final StringgetRange()Returns the first"Range"header ornullfor none.final StringReturns the first"Retry-After"header ornullfor none.final StringReturns the first"User-Agent"header ornullfor none.Returns all"Warning"headers ornullfor none.static voidserializeHeadersForMultipartRequests(HttpHeaders headers, StringBuilder logbuf, Logger logger, Writer writer) Serializes headers to anWriterfor Multi-part requests.Sets the given field value (may benull) for the given field name.Sets the"Accept"header ornullfor none.setAcceptEncoding(String acceptEncoding) Sets the"Accept-Encoding"header ornullfor none.Sets the"Age"header ornullfor none.setAuthenticate(String authenticate) Sets the"WWW-Authenticate"header ornullfor none.setAuthorization(String authorization) Sets the"Authorization"header ornullfor none.setAuthorization(List<String> authorization) Sets the"Authorization"header ornullfor none.setBasicAuthentication(String username, String password) Sets theauthorizationheader as specified in Basic Authentication Scheme.setCacheControl(String cacheControl) Sets the"Cache-Control"header ornullfor none.setContentEncoding(String contentEncoding) Sets the"Content-Encoding"header ornullfor none.setContentLength(Long contentLength) Sets the"Content-Length"header ornullfor none.setContentMD5(String contentMD5) Sets the"Content-MD5"header ornullfor none.setContentRange(String contentRange) Sets the"Content-Range"header ornullfor none.setContentType(String contentType) Sets the"Content-Type"header ornullfor none.Sets the"Cookie"header ornullfor none.Sets the"Date"header ornullfor none.Sets the"ETag"header ornullfor none.setExpires(String expires) Sets the"Expires"header ornullfor none.setIfMatch(String ifMatch) Sets the"If-Match"header ornullfor none.setIfModifiedSince(String ifModifiedSince) Sets the"If-Modified-Since"header ornullfor none.setIfNoneMatch(String ifNoneMatch) Sets the"If-None-Match"header ornullfor none.setIfRange(String ifRange) Sets the"If-Range"header ornullfor none.setIfUnmodifiedSince(String ifUnmodifiedSince) Sets the"If-Unmodified-Since"header ornullfor none.setLastModified(String lastModified) Sets the"Last-Modified"header ornullfor none.setLocation(String location) Sets the"Location"header ornullfor none.setMimeVersion(String mimeVersion) Sets the"MIME-Version"header ornullfor none.Sets the"Range"header ornullfor none.setRetryAfter(String retryAfter) Sets the"Retry-After"header ornullfor none.setUserAgent(String userAgent) Sets the"User-Agent"header ornullfor none.Methods inherited from class GenericData
entrySet, equals, get, getClassInfo, getUnknownKeys, hashCode, put, putAll, remove, setUnknownKeys, toStringMethods inherited from class AbstractMap
clear, containsKey, containsValue, isEmpty, keySet, size, valuesMethods inherited from interface Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
HttpHeaders
public HttpHeaders()
-
-
Method Details
-
clone
Description copied from class:GenericDataMakes a "deep" clone of the generic data, in which the clone is completely independent of the original.- Overrides:
clonein classGenericData
-
set
Description copied from class:GenericDataSets the given field value (may benull) for the given field name. Any existing value for the field will be overwritten. It may be more slightly more efficient thanGenericData.put(String, Object)because it avoids accessing the field's original value.Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
- Overrides:
setin classGenericData
-
getAccept
-
setAccept
Sets the"Accept"header ornullfor none.Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
- Since:
- 1.5
-
getAcceptEncoding
Returns the first"Accept-Encoding"header ornullfor none.- Since:
- 1.5
-
setAcceptEncoding
Sets the"Accept-Encoding"header ornullfor none.By default, this is
"gzip".- Since:
- 1.5
-
getAuthorization
Returns the first"Authorization"header ornullfor none.- Since:
- 1.5
-
getAuthorizationAsList
-
setAuthorization
Sets the"Authorization"header ornullfor none.Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
- Since:
- 1.5
-
setAuthorization
Sets the"Authorization"header ornullfor none.Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
- Since:
- 1.13
-
getCacheControl
Returns the first"Cache-Control"header ornullfor none.- Since:
- 1.5
-
setCacheControl
Sets the"Cache-Control"header ornullfor none.Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
- Since:
- 1.5
-
getContentEncoding
Returns the first"Content-Encoding"header ornullfor none.- Since:
- 1.5
-
setContentEncoding
Sets the"Content-Encoding"header ornullfor none.Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
- Since:
- 1.5
-
getContentLength
Returns the first"Content-Length"header ornullfor none.- Since:
- 1.5
-
setContentLength
Sets the"Content-Length"header ornullfor none.Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
- Since:
- 1.5
-
getContentMD5
Returns the first"Content-MD5"header ornullfor none.- Since:
- 1.5
-
setContentMD5
Sets the"Content-MD5"header ornullfor none.Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
- Since:
- 1.5
-
getContentRange
Returns the first"Content-Range"header ornullfor none.- Since:
- 1.5
-
setContentRange
Sets the"Content-Range"header ornullfor none.Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
- Since:
- 1.5
-
getContentType
Returns the first"Content-Type"header ornullfor none.- Since:
- 1.5
-
setContentType
Sets the"Content-Type"header ornullfor none.Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
- Since:
- 1.5
-
getCookie
- Since:
- 1.6
-
setCookie
Sets the"Cookie"header ornullfor none.Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
- Since:
- 1.6
-
getDate
-
setDate
Sets the"Date"header ornullfor none.Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
- Since:
- 1.5
-
getETag
-
setETag
Sets the"ETag"header ornullfor none.Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
- Since:
- 1.5
-
getExpires
-
setExpires
Sets the"Expires"header ornullfor none.Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
- Since:
- 1.5
-
getIfModifiedSince
Returns the first"If-Modified-Since"header ornullfor none.- Since:
- 1.5
-
setIfModifiedSince
Sets the"If-Modified-Since"header ornullfor none.Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
- Since:
- 1.5
-
getIfMatch
-
setIfMatch
Sets the"If-Match"header ornullfor none.Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
- Since:
- 1.5
-
getIfNoneMatch
Returns the first"If-None-Match"header ornullfor none.- Since:
- 1.5
-
setIfNoneMatch
Sets the"If-None-Match"header ornullfor none.Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
- Since:
- 1.5
-
getIfUnmodifiedSince
Returns the first"If-Unmodified-Since"header ornullfor none.- Since:
- 1.5
-
setIfUnmodifiedSince
Sets the"If-Unmodified-Since"header ornullfor none.Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
- Since:
- 1.5
-
getIfRange
-
setIfRange
Sets the"If-Range"header ornullfor none.Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
- Since:
- 1.14
-
getLastModified
Returns the first"Last-Modified"header ornullfor none.- Since:
- 1.5
-
setLastModified
Sets the"Last-Modified"header ornullfor none.Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
- Since:
- 1.5
-
getLocation
-
setLocation
Sets the"Location"header ornullfor none.Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
- Since:
- 1.5
-
getMimeVersion
Returns the first"MIME-Version"header ornullfor none.- Since:
- 1.5
-
setMimeVersion
Sets the"MIME-Version"header ornullfor none.Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
- Since:
- 1.5
-
getRange
-
setRange
Sets the"Range"header ornullfor none.Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
- Since:
- 1.5
-
getRetryAfter
Returns the first"Retry-After"header ornullfor none.- Since:
- 1.5
-
setRetryAfter
Sets the"Retry-After"header ornullfor none.Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
- Since:
- 1.5
-
getUserAgent
Returns the first"User-Agent"header ornullfor none.- Since:
- 1.5
-
setUserAgent
Sets the"User-Agent"header ornullfor none.Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
- Since:
- 1.5
-
getAuthenticate
Returns the first"WWW-Authenticate"header ornullfor none.- Since:
- 1.5
-
getAuthenticateAsList
-
setAuthenticate
Sets the"WWW-Authenticate"header ornullfor none.Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
- Since:
- 1.5
-
addWarning
Adds the"Warning"header ornullfor none.Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
- Since:
- 1.28
-
getWarning
-
getAge
-
setAge
Sets the"Age"header ornullfor none.Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
- Since:
- 1.14
-
setBasicAuthentication
Sets theauthorizationheader as specified in Basic Authentication Scheme.Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
- Since:
- 1.2
-
serializeHeadersForMultipartRequests
public static void serializeHeadersForMultipartRequests(HttpHeaders headers, StringBuilder logbuf, Logger logger, Writer writer) throws IOException Serializes headers to anWriterfor Multi-part requests.- Parameters:
headers- HTTP headerslogbuf- log buffer ornullfor nonelogger- logger ornullfor none. Logger must be specified if log buffer is specifiedwriter- Writer where HTTP headers will be serialized to ornullfor none- Throws:
IOException- Since:
- 1.9
-
fromHttpResponse
public final void fromHttpResponse(LowLevelHttpResponse response, StringBuilder logger) throws IOException Puts all headers of theLowLevelHttpResponseinto thisHttpHeadersobject.- Parameters:
response- Response from which the headers are copiedlogger-StringBuilderto which logging output is added ornullto disable logging- Throws:
IOException- Since:
- 1.10
-
getFirstHeaderStringValue
-
getHeaderStringValues
-
fromHttpHeaders
Puts all headers of theHttpHeadersobject into thisHttpHeadersobject.- Parameters:
headers-HttpHeadersfrom where the headers are taken- Since:
- 1.10
-