public class HttpHeaders extends GenericData
null
is not allowed as a name or value of a header. Names are case-insensitive.
Implementation is not thread-safe.
GenericData.Flags
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Constructor and Description |
---|
HttpHeaders() |
Modifier and Type | Method and Description |
---|---|
HttpHeaders |
addWarning(String warning)
Adds the
"Warning" header or null for none. |
HttpHeaders |
clone()
Makes a "deep" clone of the generic data, in which the clone is completely independent of the
original.
|
void |
fromHttpHeaders(HttpHeaders headers)
Puts all headers of the
HttpHeaders object into this HttpHeaders object. |
void |
fromHttpResponse(LowLevelHttpResponse response,
StringBuilder logger)
Puts all headers of the
LowLevelHttpResponse into this HttpHeaders object. |
String |
getAccept()
Returns the first
"Accept" header or null for none. |
String |
getAcceptEncoding()
Returns the first
"Accept-Encoding" header or null for none. |
Long |
getAge()
Returns the first
"Age" header or null for none. |
String |
getAuthenticate()
Returns the first
"WWW-Authenticate" header or null for none. |
List<String> |
getAuthenticateAsList()
Returns all
"WWW-Authenticate" headers or null for none. |
String |
getAuthorization()
Returns the first
"Authorization" header or null for none. |
List<String> |
getAuthorizationAsList()
Returns all
"Authorization" headers or null for none. |
String |
getCacheControl()
Returns the first
"Cache-Control" header or null for none. |
String |
getContentEncoding()
Returns the first
"Content-Encoding" header or null for none. |
Long |
getContentLength()
Returns the first
"Content-Length" header or null for none. |
String |
getContentMD5()
Returns the first
"Content-MD5" header or null for none. |
String |
getContentRange()
Returns the first
"Content-Range" header or null for none. |
String |
getContentType()
Returns the first
"Content-Type" header or null for none. |
String |
getCookie()
Returns the first
"Cookie" header or null for none. |
String |
getDate()
Returns the first
"Date" header or null for none. |
String |
getETag()
Returns the first
"ETag" header or null for none. |
String |
getExpires()
Returns the first
"Expires" header or null for none. |
String |
getFirstHeaderStringValue(String name)
Returns the first header string value for the given header name.
|
List<String> |
getHeaderStringValues(String name)
Returns an unmodifiable list of the header string values for the given header name.
|
String |
getIfMatch()
Returns the first
"If-Match" header or null for none. |
String |
getIfModifiedSince()
Returns the first
"If-Modified-Since" header or null for none. |
String |
getIfNoneMatch()
Returns the first
"If-None-Match" header or null for none. |
String |
getIfRange()
Returns the first
"If-Range" header or null for none. |
String |
getIfUnmodifiedSince()
Returns the first
"If-Unmodified-Since" header or null for none. |
String |
getLastModified()
Returns the first
"Last-Modified" header or null for none. |
String |
getLocation()
Returns the first
"Location" header or null for none. |
String |
getMimeVersion()
Returns the first
"MIME-Version" header or null for none. |
String |
getRange()
Returns the first
"Range" header or null for none. |
String |
getRetryAfter()
Returns the first
"Retry-After" header or null for none. |
String |
getUserAgent()
Returns the first
"User-Agent" header or null for none. |
List<String> |
getWarning()
Returns all
"Warning" headers or null for none. |
static void |
serializeHeadersForMultipartRequests(HttpHeaders headers,
StringBuilder logbuf,
Logger logger,
Writer writer)
Serializes headers to an
Writer for Multi-part requests. |
HttpHeaders |
set(String fieldName,
Object value)
Sets the given field value (may be
null ) for the given field name. |
HttpHeaders |
setAccept(String accept)
Sets the
"Accept" header or null for none. |
HttpHeaders |
setAcceptEncoding(String acceptEncoding)
Sets the
"Accept-Encoding" header or null for none. |
HttpHeaders |
setAge(Long age)
Sets the
"Age" header or null for none. |
HttpHeaders |
setAuthenticate(String authenticate)
Sets the
"WWW-Authenticate" header or null for none. |
HttpHeaders |
setAuthorization(List<String> authorization)
Sets the
"Authorization" header or null for none. |
HttpHeaders |
setAuthorization(String authorization)
Sets the
"Authorization" header or null for none. |
HttpHeaders |
setBasicAuthentication(String username,
String password)
Sets the
authorization header as specified in Basic Authentication Scheme. |
HttpHeaders |
setCacheControl(String cacheControl)
Sets the
"Cache-Control" header or null for none. |
HttpHeaders |
setContentEncoding(String contentEncoding)
Sets the
"Content-Encoding" header or null for none. |
HttpHeaders |
setContentLength(Long contentLength)
Sets the
"Content-Length" header or null for none. |
HttpHeaders |
setContentMD5(String contentMD5)
Sets the
"Content-MD5" header or null for none. |
HttpHeaders |
setContentRange(String contentRange)
Sets the
"Content-Range" header or null for none. |
HttpHeaders |
setContentType(String contentType)
Sets the
"Content-Type" header or null for none. |
HttpHeaders |
setCookie(String cookie)
Sets the
"Cookie" header or null for none. |
HttpHeaders |
setDate(String date)
Sets the
"Date" header or null for none. |
HttpHeaders |
setETag(String etag)
Sets the
"ETag" header or null for none. |
HttpHeaders |
setExpires(String expires)
Sets the
"Expires" header or null for none. |
HttpHeaders |
setIfMatch(String ifMatch)
Sets the
"If-Match" header or null for none. |
HttpHeaders |
setIfModifiedSince(String ifModifiedSince)
Sets the
"If-Modified-Since" header or null for none. |
HttpHeaders |
setIfNoneMatch(String ifNoneMatch)
Sets the
"If-None-Match" header or null for none. |
HttpHeaders |
setIfRange(String ifRange)
Sets the
"If-Range" header or null for none. |
HttpHeaders |
setIfUnmodifiedSince(String ifUnmodifiedSince)
Sets the
"If-Unmodified-Since" header or null for none. |
HttpHeaders |
setLastModified(String lastModified)
Sets the
"Last-Modified" header or null for none. |
HttpHeaders |
setLocation(String location)
Sets the
"Location" header or null for none. |
HttpHeaders |
setMimeVersion(String mimeVersion)
Sets the
"MIME-Version" header or null for none. |
HttpHeaders |
setRange(String range)
Sets the
"Range" header or null for none. |
HttpHeaders |
setRetryAfter(String retryAfter)
Sets the
"Retry-After" header or null for none. |
HttpHeaders |
setUserAgent(String userAgent)
Sets the
"User-Agent" header or null for none. |
entrySet, equals, get, getClassInfo, getUnknownKeys, hashCode, put, putAll, remove, setUnknownKeys, toString
clear, containsKey, containsValue, isEmpty, keySet, size, values
finalize, getClass, notify, notifyAll, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
public HttpHeaders clone()
GenericData
clone
in class GenericData
public HttpHeaders set(String fieldName, Object value)
GenericData
null
) for the given field name. Any existing value
for the field will be overwritten. It may be more slightly more efficient than GenericData.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.
set
in class GenericData
public final String getAccept()
"Accept"
header or null
for none.public HttpHeaders setAccept(String accept)
"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.
public final String getAcceptEncoding()
"Accept-Encoding"
header or null
for none.public HttpHeaders setAcceptEncoding(String acceptEncoding)
"Accept-Encoding"
header or null
for none.
By default, this is "gzip"
.
public final String getAuthorization()
"Authorization"
header or null
for none.public final List<String> getAuthorizationAsList()
"Authorization"
headers or null
for none.public HttpHeaders setAuthorization(String authorization)
"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.
public HttpHeaders setAuthorization(List<String> authorization)
"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.
public final String getCacheControl()
"Cache-Control"
header or null
for none.public HttpHeaders setCacheControl(String cacheControl)
"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.
public final String getContentEncoding()
"Content-Encoding"
header or null
for none.public HttpHeaders setContentEncoding(String contentEncoding)
"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.
public final Long getContentLength()
"Content-Length"
header or null
for none.public HttpHeaders setContentLength(Long contentLength)
"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.
public final String getContentMD5()
"Content-MD5"
header or null
for none.public HttpHeaders setContentMD5(String contentMD5)
"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.
public final String getContentRange()
"Content-Range"
header or null
for none.public HttpHeaders setContentRange(String contentRange)
"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.
public final String getContentType()
"Content-Type"
header or null
for none.public HttpHeaders setContentType(String contentType)
"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.
public final String getCookie()
public HttpHeaders setCookie(String cookie)
"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.
public final String getDate()
"Date"
header or null
for none.public HttpHeaders setDate(String date)
"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.
public final String getETag()
"ETag"
header or null
for none.public HttpHeaders setETag(String etag)
"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.
public final String getExpires()
"Expires"
header or null
for none.public HttpHeaders setExpires(String expires)
"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.
public final String getIfModifiedSince()
"If-Modified-Since"
header or null
for none.public HttpHeaders setIfModifiedSince(String ifModifiedSince)
"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.
public final String getIfMatch()
"If-Match"
header or null
for none.public HttpHeaders setIfMatch(String ifMatch)
"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.
public final String getIfNoneMatch()
"If-None-Match"
header or null
for none.public HttpHeaders setIfNoneMatch(String ifNoneMatch)
"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.
public final String getIfUnmodifiedSince()
"If-Unmodified-Since"
header or null
for none.public HttpHeaders setIfUnmodifiedSince(String ifUnmodifiedSince)
"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.
public final String getIfRange()
"If-Range"
header or null
for none.public HttpHeaders setIfRange(String ifRange)
"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.
public final String getLastModified()
"Last-Modified"
header or null
for none.public HttpHeaders setLastModified(String lastModified)
"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.
public final String getLocation()
"Location"
header or null
for none.public HttpHeaders setLocation(String location)
"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.
public final String getMimeVersion()
"MIME-Version"
header or null
for none.public HttpHeaders setMimeVersion(String mimeVersion)
"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.
public final String getRange()
"Range"
header or null
for none.public HttpHeaders setRange(String range)
"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.
public final String getRetryAfter()
"Retry-After"
header or null
for none.public HttpHeaders setRetryAfter(String retryAfter)
"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.
public final String getUserAgent()
"User-Agent"
header or null
for none.public HttpHeaders setUserAgent(String userAgent)
"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.
public final String getAuthenticate()
"WWW-Authenticate"
header or null
for none.public final List<String> getAuthenticateAsList()
"WWW-Authenticate"
headers or null
for none.public HttpHeaders setAuthenticate(String authenticate)
"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.
public HttpHeaders addWarning(String warning)
"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.
public final List<String> getWarning()
"Warning"
headers or null
for none.public final Long getAge()
"Age"
header or null
for none.public HttpHeaders setAge(Long age)
"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.
public HttpHeaders setBasicAuthentication(String username, String password)
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.
public static void serializeHeadersForMultipartRequests(HttpHeaders headers, StringBuilder logbuf, Logger logger, Writer writer) throws IOException
Writer
for Multi-part requests.headers
- HTTP headerslogbuf
- log buffer or null
for nonelogger
- logger or null
for none. Logger must be specified if log buffer is
specifiedwriter
- Writer where HTTP headers will be serialized to or null
for noneIOException
public final void fromHttpResponse(LowLevelHttpResponse response, StringBuilder logger) throws IOException
LowLevelHttpResponse
into this HttpHeaders
object.response
- Response from which the headers are copiedlogger
- StringBuilder
to which logging output is added or null
to disable
loggingIOException
public String getFirstHeaderStringValue(String name)
name
- header name (may be any case)null
if not foundpublic List<String> getHeaderStringValues(String name)
name
- header name (may be any case)public final void fromHttpHeaders(HttpHeaders headers)
HttpHeaders
object into this HttpHeaders
object.headers
- HttpHeaders
from where the headers are takenCopyright © 2011–2019 Google. All rights reserved.