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 |
clone()
Makes a "deep" clone of the generic data, in which the clone is completely independent of the original.
|
void |
fromHttpHeaders(HttpHeaders
Puts all headers of the
HttpHeaders object into this
HttpHeaders object.
|
void |
fromHttpResponse(LowLevelHttpResponse
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 |
getAuthenticateAsList()
Returns all
"WWW-Authenticate" headers or
null for none.
|
String |
getAuthorization()
Returns the first
"Authorization" header or
null for none.
|
List |
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
Returns the first header string value for the given header name.
|
List |
getHeaderStringValues(String
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.
|
static void |
serializeHeadersForMultipartRequests(HttpHeaders
Serializes headers to an
Writer for Multi-part requests.
|
HttpHeaders |
set(String
Sets the given field value (may be
null) for the given field name.
|
HttpHeaders |
setAccept(String
Sets the
"Accept" header or
null for none.
|
HttpHeaders |
setAcceptEncoding(String
Sets the
"Accept-Encoding" header or
null for none.
|
HttpHeaders |
setAge(Long
Sets the
"Age" header or
null for none.
|
HttpHeaders |
setAuthenticate(String
Sets the
"WWW-Authenticate" header or
null for none.
|
HttpHeaders |
setAuthorization(List
Sets the
"Authorization" header or
null for none.
|
HttpHeaders |
setAuthorization(String
Sets the
"Authorization" header or
null for none.
|
HttpHeaders |
setBasicAuthentication(String
Sets the
authorization header as specified in
Basic Authentication Scheme.
|
HttpHeaders |
setCacheControl(String
Sets the
"Cache-Control" header or
null for none.
|
HttpHeaders |
setContentEncoding(String
Sets the
"Content-Encoding" header or
null for none.
|
HttpHeaders |
setContentLength(Long
Sets the
"Content-Length" header or
null for none.
|
HttpHeaders |
setContentMD5(String
Sets the
"Content-MD5" header or
null for none.
|
HttpHeaders |
setContentRange(String
Sets the
"Content-Range" header or
null for none.
|
HttpHeaders |
setContentType(String
Sets the
"Content-Type" header or
null for none.
|
HttpHeaders |
setCookie(String
Sets the
"Cookie" header or
null for none.
|
HttpHeaders |
setDate(String
Sets the
"Date" header or
null for none.
|
HttpHeaders |
setETag(String
Sets the
"ETag" header or
null for none.
|
HttpHeaders |
setExpires(String
Sets the
"Expires" header or
null for none.
|
HttpHeaders |
setIfMatch(String
Sets the
"If-Match" header or
null for none.
|
HttpHeaders |
setIfModifiedSince(String
Sets the
"If-Modified-Since" header or
null for none.
|
HttpHeaders |
setIfNoneMatch(String
Sets the
"If-None-Match" header or
null for none.
|
HttpHeaders |
setIfRange(String
Sets the
"If-Range" header or
null for none.
|
HttpHeaders |
setIfUnmodifiedSince(String
Sets the
"If-Unmodified-Since" header or
null for none.
|
HttpHeaders |
setLastModified(String
Sets the
"Last-Modified" header or
null for none.
|
HttpHeaders |
setLocation(String
Sets the
"Location" header or
null for none.
|
HttpHeaders |
setMimeVersion(String
Sets the
"MIME-Version" header or
null for none.
|
HttpHeaders |
setRange(String
Sets the
"Range" header or
null for none.
|
HttpHeaders |
setRetryAfter(String
Sets the
"Retry-After" header or
null for none.
|
HttpHeaders |
setUserAgent(String
Sets the
"User-Agent" header or
null for none.
|
entrySet, get, getClassInfo, getUnknownKeys, put, putAll, remove, setUnknownKeysclear, containsKey, containsValue, equals, hashCode, isEmpty, keySet, size, toString, valuesfinalize, getClass, notify, notifyAll, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAllpublic HttpHeadersclone()
GenericData
public HttpHeadersset(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.
public final StringgetAccept()
"Accept" header or
null for none.
public HttpHeaderssetAccept(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 StringgetAcceptEncoding()
"Accept-Encoding" header or
null for none.
public HttpHeaderssetAcceptEncoding(String acceptEncoding)
"Accept-Encoding" header or
null for none.
By default, this is "gzip".
public final StringgetAuthorization()
"Authorization" header or
null for none.
public final List<String > getAuthorizationAsList()
"Authorization" headers or
null for none.
public HttpHeaderssetAuthorization(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 HttpHeaderssetAuthorization(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 StringgetCacheControl()
"Cache-Control" header or
null for none.
public HttpHeaderssetCacheControl(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 StringgetContentEncoding()
"Content-Encoding" header or
null for none.
public HttpHeaderssetContentEncoding(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 LonggetContentLength()
"Content-Length" header or
null for none.
public HttpHeaderssetContentLength(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 StringgetContentMD5()
"Content-MD5" header or
null for none.
public HttpHeaderssetContentMD5(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 StringgetContentRange()
"Content-Range" header or
null for none.
public HttpHeaderssetContentRange(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 StringgetContentType()
"Content-Type" header or
null for none.
public HttpHeaderssetContentType(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 StringgetCookie()
public HttpHeaderssetCookie(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 StringgetDate()
"Date" header or
null for none.
public HttpHeaderssetDate(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 StringgetETag()
"ETag" header or
null for none.
public HttpHeaderssetETag(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 StringgetExpires()
"Expires" header or
null for none.
public HttpHeaderssetExpires(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 StringgetIfModifiedSince()
"If-Modified-Since" header or
null for none.
public HttpHeaderssetIfModifiedSince(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 StringgetIfMatch()
"If-Match" header or
null for none.
public HttpHeaderssetIfMatch(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 StringgetIfNoneMatch()
"If-None-Match" header or
null for none.
public HttpHeaderssetIfNoneMatch(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 StringgetIfUnmodifiedSince()
"If-Unmodified-Since" header or
null for none.
public HttpHeaderssetIfUnmodifiedSince(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 StringgetIfRange()
"If-Range" header or
null for none.
public HttpHeaderssetIfRange(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 StringgetLastModified()
"Last-Modified" header or
null for none.
public HttpHeaderssetLastModified(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 StringgetLocation()
"Location" header or
null for none.
public HttpHeaderssetLocation(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 StringgetMimeVersion()
"MIME-Version" header or
null for none.
public HttpHeaderssetMimeVersion(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 StringgetRange()
"Range" header or
null for none.
public HttpHeaderssetRange(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 StringgetRetryAfter()
"Retry-After" header or
null for none.
public HttpHeaderssetRetryAfter(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 StringgetUserAgent()
"User-Agent" header or
null for none.
public HttpHeaderssetUserAgent(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 StringgetAuthenticate()
"WWW-Authenticate" header or
null for none.
public final List<String > getAuthenticateAsList()
"WWW-Authenticate" headers or
null for none.
public HttpHeaderssetAuthenticate(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 final LonggetAge()
"Age" header or
null for none.
public HttpHeaderssetAge(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 HttpHeaderssetBasicAuthentication(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(HttpHeadersheaders, StringBuilder logbuf, Logger logger, Writer writer) throws IOException
Writer for Multi-part requests.
headers - HTTP headers
logbuf - log buffer or
null for none
logger - logger or
null for none. Logger must be specified if log buffer is specified
writer - Writer where HTTP headers will be serialized to or
null for none
IOException
public final void fromHttpResponse(LowLevelHttpResponseresponse, StringBuilder logger) throws IOException
LowLevelHttpResponse into this
HttpHeaders object.
response - Response from which the headers are copied
logger -
StringBuilder to which logging output is added or
null to disable logging
IOException
public StringgetFirstHeaderStringValue(String name)
name - header name (may be any case)
null if not found
public List<String > getHeaderStringValues(String name)
name - header name (may be any case)
public final void fromHttpHeaders(HttpHeadersheaders)
HttpHeaders object into this
HttpHeaders object.
headers -
HttpHeaders from where the headers are taken