public class HttpHeaders extends GenericData
Stores HTTP headers used in an HTTP request or response, as defined in Header Field Definitions.
null
is not allowed as a name or value of a header. Names are case-insensitive.
Implementation is not thread-safe.
Static Methods
serializeHeadersForMultipartRequests(HttpHeaders headers, StringBuilder logbuf, Logger logger, Writer writer)
public static void serializeHeadersForMultipartRequests(HttpHeaders headers, StringBuilder logbuf, Logger logger, Writer writer)
Serializes headers to an Writer for Multi-part requests.
Parameters | |
---|---|
Name | Description |
headers | HttpHeaders HTTP headers |
logbuf | StringBuilder log buffer or |
logger | Logger logger or |
writer | Writer Writer where HTTP headers will be serialized to or |
Exceptions | |
---|---|
Type | Description |
IOException |
Constructors
HttpHeaders()
public HttpHeaders()
Methods
addWarning(String warning)
public HttpHeaders addWarning(String warning)
Adds the "Warning"
header or null
for none.
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
Parameter | |
---|---|
Name | Description |
warning | String |
Returns | |
---|---|
Type | Description |
HttpHeaders |
clone()
public HttpHeaders clone()
Makes a "deep" clone of the generic data, in which the clone is completely independent of the original.
Returns | |
---|---|
Type | Description |
HttpHeaders |
fromHttpHeaders(HttpHeaders headers)
public final void fromHttpHeaders(HttpHeaders headers)
Puts all headers of the HttpHeaders object into this HttpHeaders object.
Parameter | |
---|---|
Name | Description |
headers | HttpHeaders HttpHeaders from where the headers are taken |
fromHttpResponse(LowLevelHttpResponse response, StringBuilder logger)
public final void fromHttpResponse(LowLevelHttpResponse response, StringBuilder logger)
Puts all headers of the LowLevelHttpResponse into this HttpHeaders object.
Parameters | |
---|---|
Name | Description |
response | LowLevelHttpResponse Response from which the headers are copied |
logger | StringBuilder StringBuilder to which logging output is added or |
Exceptions | |
---|---|
Type | Description |
IOException |
getAccept()
public final String getAccept()
Returns the first "Accept"
header or null
for none.
Returns | |
---|---|
Type | Description |
String |
getAcceptEncoding()
public final String getAcceptEncoding()
Returns the first "Accept-Encoding"
header or null
for none.
Returns | |
---|---|
Type | Description |
String |
getAge()
public final Long getAge()
Returns the first "Age"
header or null
for none.
Returns | |
---|---|
Type | Description |
Long |
getAuthenticate()
public final String getAuthenticate()
Returns the first "WWW-Authenticate"
header or null
for none.
Returns | |
---|---|
Type | Description |
String |
getAuthenticateAsList()
public final List<String> getAuthenticateAsList()
Returns all "WWW-Authenticate"
headers or null
for none.
Returns | |
---|---|
Type | Description |
List<String> |
getAuthorization()
public final String getAuthorization()
Returns the first "Authorization"
header or null
for none.
Returns | |
---|---|
Type | Description |
String |
getAuthorizationAsList()
public final List<String> getAuthorizationAsList()
Returns all "Authorization"
headers or null
for none.
Returns | |
---|---|
Type | Description |
List<String> |
getCacheControl()
public final String getCacheControl()
Returns the first "Cache-Control"
header or null
for none.
Returns | |
---|---|
Type | Description |
String |
getContentEncoding()
public final String getContentEncoding()
Returns the first "Content-Encoding"
header or null
for none.
Returns | |
---|---|
Type | Description |
String |
getContentLength()
public final Long getContentLength()
Returns the first "Content-Length"
header or null
for none.
Returns | |
---|---|
Type | Description |
Long |
getContentMD5()
public final String getContentMD5()
Returns the first "Content-MD5"
header or null
for none.
Returns | |
---|---|
Type | Description |
String |
getContentRange()
public final String getContentRange()
Returns the first "Content-Range"
header or null
for none.
Returns | |
---|---|
Type | Description |
String |
getContentType()
public final String getContentType()
Returns the first "Content-Type"
header or null
for none.
Returns | |
---|---|
Type | Description |
String |
getCookie()
public final String getCookie()
Returns | |
---|---|
Type | Description |
String |
getDate()
public final String getDate()
Returns the first "Date"
header or null
for none.
Returns | |
---|---|
Type | Description |
String |
getETag()
public final String getETag()
Returns the first "ETag"
header or null
for none.
Returns | |
---|---|
Type | Description |
String |
getExpires()
public final String getExpires()
Returns the first "Expires"
header or null
for none.
Returns | |
---|---|
Type | Description |
String |
getFirstHeaderStringValue(String name)
public String getFirstHeaderStringValue(String name)
Returns the first header string value for the given header name.
Parameter | |
---|---|
Name | Description |
name | String header name (may be any case) |
Returns | |
---|---|
Type | Description |
String | first header string value or |
getHeaderStringValues(String name)
public List<String> getHeaderStringValues(String name)
Returns an unmodifiable list of the header string values for the given header name.
Parameter | |
---|---|
Name | Description |
name | String header name (may be any case) |
Returns | |
---|---|
Type | Description |
List<String> | header string values or empty if not found |
getIfMatch()
public final String getIfMatch()
Returns the first "If-Match"
header or null
for none.
Returns | |
---|---|
Type | Description |
String |
getIfModifiedSince()
public final String getIfModifiedSince()
Returns the first "If-Modified-Since"
header or null
for none.
Returns | |
---|---|
Type | Description |
String |
getIfNoneMatch()
public final String getIfNoneMatch()
Returns the first "If-None-Match"
header or null
for none.
Returns | |
---|---|
Type | Description |
String |
getIfRange()
public final String getIfRange()
Returns the first "If-Range"
header or null
for none.
Returns | |
---|---|
Type | Description |
String |
getIfUnmodifiedSince()
public final String getIfUnmodifiedSince()
Returns the first "If-Unmodified-Since"
header or null
for none.
Returns | |
---|---|
Type | Description |
String |
getLastModified()
public final String getLastModified()
Returns the first "Last-Modified"
header or null
for none.
Returns | |
---|---|
Type | Description |
String |
getLocation()
public final String getLocation()
Returns the first "Location"
header or null
for none.
Returns | |
---|---|
Type | Description |
String |
getMimeVersion()
public final String getMimeVersion()
Returns the first "MIME-Version"
header or null
for none.
Returns | |
---|---|
Type | Description |
String |
getRange()
public final String getRange()
Returns the first "Range"
header or null
for none.
Returns | |
---|---|
Type | Description |
String |
getRetryAfter()
public final String getRetryAfter()
Returns the first "Retry-After"
header or null
for none.
Returns | |
---|---|
Type | Description |
String |
getUserAgent()
public final String getUserAgent()
Returns the first "User-Agent"
header or null
for none.
Returns | |
---|---|
Type | Description |
String |
getWarning()
public final List<String> getWarning()
Returns all "Warning"
headers or null
for none.
Returns | |
---|---|
Type | Description |
List<String> |
set(String fieldName, Object value)
public HttpHeaders set(String fieldName, Object value)
Sets the given field value (may be null
) for the given field name. Any existing value
for the field will be overwritten. It may be more slightly more efficient than #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.
Parameters | |
---|---|
Name | Description |
fieldName | String |
value | Object |
Returns | |
---|---|
Type | Description |
HttpHeaders |
setAccept(String accept)
public HttpHeaders setAccept(String accept)
Sets the "Accept"
header or null
for none.
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
Parameter | |
---|---|
Name | Description |
accept | String |
Returns | |
---|---|
Type | Description |
HttpHeaders |
setAcceptEncoding(String acceptEncoding)
public HttpHeaders setAcceptEncoding(String acceptEncoding)
Sets the "Accept-Encoding"
header or null
for none.
By default, this is "gzip"
.
Parameter | |
---|---|
Name | Description |
acceptEncoding | String |
Returns | |
---|---|
Type | Description |
HttpHeaders |
setAge(Long age)
public HttpHeaders setAge(Long age)
Sets the "Age"
header or null
for none.
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
Parameter | |
---|---|
Name | Description |
age | Long |
Returns | |
---|---|
Type | Description |
HttpHeaders |
setAuthenticate(String authenticate)
public HttpHeaders setAuthenticate(String authenticate)
Sets the "WWW-Authenticate"
header or null
for none.
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
Parameter | |
---|---|
Name | Description |
authenticate | String |
Returns | |
---|---|
Type | Description |
HttpHeaders |
setAuthorization(String authorization)
public HttpHeaders setAuthorization(String authorization)
Sets the "Authorization"
header or null
for none.
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
Parameter | |
---|---|
Name | Description |
authorization | String |
Returns | |
---|---|
Type | Description |
HttpHeaders |
setAuthorization(List<String> authorization)
public HttpHeaders setAuthorization(List<String> authorization)
Sets the "Authorization"
header or null
for none.
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
Parameter | |
---|---|
Name | Description |
authorization | List<String> |
Returns | |
---|---|
Type | Description |
HttpHeaders |
setBasicAuthentication(String username, String password)
public HttpHeaders setBasicAuthentication(String username, String password)
Sets the #authorization header 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.
Parameters | |
---|---|
Name | Description |
username | String |
password | String |
Returns | |
---|---|
Type | Description |
HttpHeaders |
setCacheControl(String cacheControl)
public HttpHeaders setCacheControl(String cacheControl)
Sets the "Cache-Control"
header or null
for none.
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
Parameter | |
---|---|
Name | Description |
cacheControl | String |
Returns | |
---|---|
Type | Description |
HttpHeaders |
setContentEncoding(String contentEncoding)
public HttpHeaders setContentEncoding(String contentEncoding)
Sets the "Content-Encoding"
header or null
for none.
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
Parameter | |
---|---|
Name | Description |
contentEncoding | String |
Returns | |
---|---|
Type | Description |
HttpHeaders |
setContentLength(Long contentLength)
public HttpHeaders setContentLength(Long contentLength)
Sets the "Content-Length"
header or null
for none.
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
Parameter | |
---|---|
Name | Description |
contentLength | Long |
Returns | |
---|---|
Type | Description |
HttpHeaders |
setContentMD5(String contentMD5)
public HttpHeaders setContentMD5(String contentMD5)
Sets the "Content-MD5"
header or null
for none.
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
Parameter | |
---|---|
Name | Description |
contentMD5 | String |
Returns | |
---|---|
Type | Description |
HttpHeaders |
setContentRange(String contentRange)
public HttpHeaders setContentRange(String contentRange)
Sets the "Content-Range"
header or null
for none.
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
Parameter | |
---|---|
Name | Description |
contentRange | String |
Returns | |
---|---|
Type | Description |
HttpHeaders |
setContentType(String contentType)
public HttpHeaders setContentType(String contentType)
Sets the "Content-Type"
header or null
for none.
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
Parameter | |
---|---|
Name | Description |
contentType | String |
Returns | |
---|---|
Type | Description |
HttpHeaders |
setCookie(String cookie)
public HttpHeaders setCookie(String cookie)
Sets the "Cookie"
header or null
for none.
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
Parameter | |
---|---|
Name | Description |
cookie | String |
Returns | |
---|---|
Type | Description |
HttpHeaders |
setDate(String date)
public HttpHeaders setDate(String date)
Sets the "Date"
header or null
for none.
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
Parameter | |
---|---|
Name | Description |
date | String |
Returns | |
---|---|
Type | Description |
HttpHeaders |
setETag(String etag)
public HttpHeaders setETag(String etag)
Sets the "ETag"
header or null
for none.
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
Parameter | |
---|---|
Name | Description |
etag | String |
Returns | |
---|---|
Type | Description |
HttpHeaders |
setExpires(String expires)
public HttpHeaders setExpires(String expires)
Sets the "Expires"
header or null
for none.
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
Parameter | |
---|---|
Name | Description |
expires | String |
Returns | |
---|---|
Type | Description |
HttpHeaders |
setIfMatch(String ifMatch)
public HttpHeaders setIfMatch(String ifMatch)
Sets the "If-Match"
header or null
for none.
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
Parameter | |
---|---|
Name | Description |
ifMatch | String |
Returns | |
---|---|
Type | Description |
HttpHeaders |
setIfModifiedSince(String ifModifiedSince)
public HttpHeaders setIfModifiedSince(String ifModifiedSince)
Sets the "If-Modified-Since"
header or null
for none.
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
Parameter | |
---|---|
Name | Description |
ifModifiedSince | String |
Returns | |
---|---|
Type | Description |
HttpHeaders |
setIfNoneMatch(String ifNoneMatch)
public HttpHeaders setIfNoneMatch(String ifNoneMatch)
Sets the "If-None-Match"
header or null
for none.
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
Parameter | |
---|---|
Name | Description |
ifNoneMatch | String |
Returns | |
---|---|
Type | Description |
HttpHeaders |
setIfRange(String ifRange)
public HttpHeaders setIfRange(String ifRange)
Sets the "If-Range"
header or null
for none.
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
Parameter | |
---|---|
Name | Description |
ifRange | String |
Returns | |
---|---|
Type | Description |
HttpHeaders |
setIfUnmodifiedSince(String ifUnmodifiedSince)
public HttpHeaders setIfUnmodifiedSince(String ifUnmodifiedSince)
Sets the "If-Unmodified-Since"
header or null
for none.
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
Parameter | |
---|---|
Name | Description |
ifUnmodifiedSince | String |
Returns | |
---|---|
Type | Description |
HttpHeaders |
setLastModified(String lastModified)
public HttpHeaders setLastModified(String lastModified)
Sets the "Last-Modified"
header or null
for none.
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
Parameter | |
---|---|
Name | Description |
lastModified | String |
Returns | |
---|---|
Type | Description |
HttpHeaders |
setLocation(String location)
public HttpHeaders setLocation(String location)
Sets the "Location"
header or null
for none.
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
Parameter | |
---|---|
Name | Description |
location | String |
Returns | |
---|---|
Type | Description |
HttpHeaders |
setMimeVersion(String mimeVersion)
public HttpHeaders setMimeVersion(String mimeVersion)
Sets the "MIME-Version"
header or null
for none.
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
Parameter | |
---|---|
Name | Description |
mimeVersion | String |
Returns | |
---|---|
Type | Description |
HttpHeaders |
setRange(String range)
public HttpHeaders setRange(String range)
Sets the "Range"
header or null
for none.
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
Parameter | |
---|---|
Name | Description |
range | String |
Returns | |
---|---|
Type | Description |
HttpHeaders |
setRetryAfter(String retryAfter)
public HttpHeaders setRetryAfter(String retryAfter)
Sets the "Retry-After"
header or null
for none.
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
Parameter | |
---|---|
Name | Description |
retryAfter | String |
Returns | |
---|---|
Type | Description |
HttpHeaders |
setUserAgent(String userAgent)
public HttpHeaders setUserAgent(String userAgent)
Sets the "User-Agent"
header or null
for none.
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
Parameter | |
---|---|
Name | Description |
userAgent | String |
Returns | |
---|---|
Type | Description |
HttpHeaders |