Top Description Fields Methods
javax.ws.rs.core

public Interface HttpHeaders

Imports
java.util.Date, .List, .Locale, .Map

An injectable interface that provides access to HTTP header information. All methods throw java.lang.IllegalStateException if called outside the scope of a request (e.g. from a provider constructor).
Authors
Paul Sandoz, Marc Hadley
Since
1.0
See Also
Context

Field Summary

Modifier and TypeField and Description
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
LAST_EVENT_ID_HEADER

"Last-Event-ID" HTTP request header name as defined by SSE specification.

public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String

Method Summary

Modifier and TypeMethod and Description
public List<Locale>

Returns:

a read-only list of acceptable languages sorted according to their q-value, with highest preference first.
getAcceptableLanguages
()

Get a list of languages that are acceptable for the response.

public List<MediaType>

Returns:

a read-only list of requested response media types sorted according to their q-value, with highest preference first.
getAcceptableMediaTypes
()

Get a list of media types that are acceptable for the response.

public Map<String, Cookie>

Returns:

a read-only map of cookie name (String) to Cookie.
getCookies
()

Get any cookies that accompanied the request.

public Date

Returns:

the message date, otherwise null if not present.
getDate
()

Get message date.

public String

Returns:

the HTTP header value. If the HTTP header is not present then null is returned. If the HTTP header is present but has no value then the empty string is returned. If the HTTP header is present more than once then the values of joined together and separated by a ',' character.
getHeaderString
(String
the HTTP header.
name
)

Get a HTTP header as a single string value.

public Locale

Returns:

the language of the entity or null if not specified.
getLanguage
()

Get the language of the request entity.

public int

Returns:

Content-Length as integer if present and valid number. In other cases returns -1.
getLength
()

Get Content-Length value.

public MediaType

Returns:

the media type or null if there is no request entity.
getMediaType
()

Get the media type of the request entity.

public List<String>

Returns:

a read-only list of header values.
getRequestHeader
(String
the header name, case insensitive.
name
)

Get the values of a HTTP request header.

public MultivaluedMap<String, String>

Returns:

a read-only map of header names and values.
getRequestHeaders
()

Get the values of HTTP request headers.

Field Detail

ACCEPTback to summary
public static final String ACCEPT

See href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1">HTTP/1.1 documentation</a>.

ACCEPT_CHARSETback to summary
public static final String ACCEPT_CHARSET

See href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.2">HTTP/1.1 documentation</a>.

ACCEPT_ENCODINGback to summary
public static final String ACCEPT_ENCODING

See href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.3">HTTP/1.1 documentation</a>.

ACCEPT_LANGUAGEback to summary
public static final String ACCEPT_LANGUAGE

See href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4">HTTP/1.1 documentation</a>.

ALLOWback to summary
public static final String ALLOW

See href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.7">HTTP/1.1 documentation</a>.

AUTHORIZATIONback to summary
public static final String AUTHORIZATION

See href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.8">HTTP/1.1 documentation</a>.

CACHE_CONTROLback to summary
public static final String CACHE_CONTROL

See href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9">HTTP/1.1 documentation</a>.

CONTENT_DISPOSITIONback to summary
public static final String CONTENT_DISPOSITION

See href="http://tools.ietf.org/html/rfc2183">IETF RFC-2183</a>.

CONTENT_ENCODINGback to summary
public static final String CONTENT_ENCODING

See href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11">HTTP/1.1 documentation</a>.

CONTENT_IDback to summary
public static final String CONTENT_ID

See href="http://tools.ietf.org/html/rfc2392">IETF RFC-2392</a>.

CONTENT_LANGUAGEback to summary
public static final String CONTENT_LANGUAGE

See href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.12">HTTP/1.1 documentation</a>.

CONTENT_LENGTHback to summary
public static final String CONTENT_LENGTH

See href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13">HTTP/1.1 documentation</a>.

CONTENT_LOCATIONback to summary
public static final String CONTENT_LOCATION

See href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.14">HTTP/1.1 documentation</a>.

CONTENT_TYPEback to summary
public static final String CONTENT_TYPE

See href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17">HTTP/1.1 documentation</a>.

DATEback to summary
public static final String DATE

See href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.18">HTTP/1.1 documentation</a>.

ETAGback to summary
public static final String ETAG

See href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.19">HTTP/1.1 documentation</a>.

EXPIRESback to summary
public static final String EXPIRES

See href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.21">HTTP/1.1 documentation</a>.

HOSTback to summary
public static final String HOST

See href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.23">HTTP/1.1 documentation</a>.

IF_MATCHback to summary
public static final String IF_MATCH

See href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.24">HTTP/1.1 documentation</a>.

IF_MODIFIED_SINCEback to summary
public static final String IF_MODIFIED_SINCE

See href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.25">HTTP/1.1 documentation</a>.

IF_NONE_MATCHback to summary
public static final String IF_NONE_MATCH

See href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.26">HTTP/1.1 documentation</a>.

IF_UNMODIFIED_SINCEback to summary
public static final String IF_UNMODIFIED_SINCE

See href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.28">HTTP/1.1 documentation</a>.

LAST_EVENT_ID_HEADERback to summary
public static final String LAST_EVENT_ID_HEADER

"Last-Event-ID" HTTP request header name as defined by SSE specification.

Since
2.1
LAST_MODIFIEDback to summary
public static final String LAST_MODIFIED

See href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.29">HTTP/1.1 documentation</a>.

LOCATIONback to summary
public static final String LOCATION

See href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.30">HTTP/1.1 documentation</a>.

RETRY_AFTERback to summary
public static final String RETRY_AFTER

See href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.37">HTTP/1.1 documentation</a>.

USER_AGENTback to summary
public static final String USER_AGENT

See href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43">HTTP/1.1 documentation</a>.

VARYback to summary
public static final String VARY

See href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.44">HTTP/1.1 documentation</a>.

WWW_AUTHENTICATEback to summary
public static final String WWW_AUTHENTICATE

See href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.47">HTTP/1.1 documentation</a>.

Method Detail

getAcceptableLanguagesback to summary
public List<Locale> getAcceptableLanguages()

Get a list of languages that are acceptable for the response.

If no acceptable languages are specified, a read-only list containing a single wildcard java.util.Locale instance (with language field set to "*") is returned.

Returns:List<Locale>

a read-only list of acceptable languages sorted according to their q-value, with highest preference first.

Exceptions
IllegalStateException:
if called outside the scope of a request.
getAcceptableMediaTypesback to summary
public List<MediaType> getAcceptableMediaTypes()

Get a list of media types that are acceptable for the response.

If no acceptable media types are specified, a read-only list containing a single wildcard media type instance is returned.

Returns:List<MediaType>

a read-only list of requested response media types sorted according to their q-value, with highest preference first.

Exceptions
IllegalStateException:
if called outside the scope of a request.
getCookiesback to summary
public Map<String, Cookie> getCookies()

Get any cookies that accompanied the request.

Returns:Map<String, Cookie>

a read-only map of cookie name (String) to Cookie.

Exceptions
IllegalStateException:
if called outside the scope of a request
getDateback to summary
public Date getDate()

Get message date.

Returns:Date

the message date, otherwise null if not present.

Since
2.0
getHeaderStringback to summary
public String getHeaderString(String name)

Get a HTTP header as a single string value.

Each single header value is converted to String using a javax.ws.rs.ext.RuntimeDelegate.HeaderDelegate if one is available via javax.ws.rs.ext.RuntimeDelegate#createHeaderDelegate(java.lang.Class) for the header value class or using its toString method if a header delegate is not available.

Parameters
name:String

the HTTP header.

Returns:String

the HTTP header value. If the HTTP header is not present then null is returned. If the HTTP header is present but has no value then the empty string is returned. If the HTTP header is present more than once then the values of joined together and separated by a ',' character.

Since
2.0
See Also
getRequestHeader(java.lang.String)
getLanguageback to summary
public Locale getLanguage()

Get the language of the request entity.

Returns:Locale

the language of the entity or null if not specified.

Exceptions
IllegalStateException:
if called outside the scope of a request.
getLengthback to summary
public int getLength()

Get Content-Length value.

Returns:int

Content-Length as integer if present and valid number. In other cases returns -1.

Since
2.0
getMediaTypeback to summary
public MediaType getMediaType()

Get the media type of the request entity.

Returns:MediaType

the media type or null if there is no request entity.

Exceptions
IllegalStateException:
if called outside the scope of a request.
getRequestHeaderback to summary
public List<String> getRequestHeader(String name)

Get the values of a HTTP request header. The returned List is read-only. This is a shortcut for getRequestHeaders().get(name).

Parameters
name:String

the header name, case insensitive.

Returns:List<String>

a read-only list of header values.

Exceptions
IllegalStateException:
if called outside the scope of a request.
getRequestHeadersback to summary
public MultivaluedMap<String, String> getRequestHeaders()

Get the values of HTTP request headers. The returned Map is case-insensitive wrt. keys and is read-only. The method never returns null.

Returns:MultivaluedMap<String, String>

a read-only map of header names and values.

Exceptions
IllegalStateException:
if called outside the scope of a request.