Package jakarta.ws.rs.core
Interface HttpHeaders
public interface HttpHeaders
An injectable interface that provides access to HTTP header information. All methods throw
 
IllegalStateException if called outside the scope of a request (e.g. from a provider constructor).- Since:
- 1.0
- Author:
- Paul Sandoz, Marc Hadley
- See Also:
- Context
- 
Field Summary
- 
Method SummaryModifier and Type Method Description List<Locale>getAcceptableLanguages()Get a list of languages that are acceptable for the response.List<MediaType>getAcceptableMediaTypes()Get a list of media types that are acceptable for the response.Map<String,Cookie>getCookies()Get any cookies that accompanied the request.DategetDate()Get message date.StringgetHeaderString(String name)Get a HTTP header as a single string value.LocalegetLanguage()Get the language of the request entity.intgetLength()Get Content-Length value.MediaTypegetMediaType()Get the media type of the request entity.List<String>getRequestHeader(String name)Get the values of a HTTP request header.MultivaluedMap<String,String>getRequestHeaders()Get the values of HTTP request headers.
- 
Field Details- 
ACCEPT- See Also:
- Constant Field Values
 
- 
ACCEPT_CHARSET- See Also:
- Constant Field Values
 
- 
ACCEPT_ENCODING- See Also:
- Constant Field Values
 
- 
ACCEPT_LANGUAGE- See Also:
- Constant Field Values
 
- 
ALLOW- See Also:
- Constant Field Values
 
- 
AUTHORIZATION- See Also:
- Constant Field Values
 
- 
CACHE_CONTROL- See Also:
- Constant Field Values
 
- 
CONTENT_DISPOSITIONSee IETF RFC-2183.- See Also:
- Constant Field Values
 
- 
CONTENT_ENCODING- See Also:
- Constant Field Values
 
- 
CONTENT_IDSee IETF RFC-2392.- See Also:
- Constant Field Values
 
- 
CONTENT_LANGUAGE- See Also:
- Constant Field Values
 
- 
CONTENT_LENGTH- See Also:
- Constant Field Values
 
- 
CONTENT_LOCATION- See Also:
- Constant Field Values
 
- 
CONTENT_TYPE- See Also:
- Constant Field Values
 
- 
DATE- See Also:
- Constant Field Values
 
- 
ETAG- See Also:
- Constant Field Values
 
- 
EXPIRES- See Also:
- Constant Field Values
 
- 
HOST- See Also:
- Constant Field Values
 
- 
IF_MATCH- See Also:
- Constant Field Values
 
- 
IF_MODIFIED_SINCE- See Also:
- Constant Field Values
 
- 
IF_NONE_MATCH- See Also:
- Constant Field Values
 
- 
IF_UNMODIFIED_SINCE- See Also:
- Constant Field Values
 
- 
LAST_MODIFIED- See Also:
- Constant Field Values
 
- 
LOCATION- See Also:
- Constant Field Values
 
- 
LINK- See Also:
- Constant Field Values
 
- 
RETRY_AFTER- See Also:
- Constant Field Values
 
- 
USER_AGENT- See Also:
- Constant Field Values
 
- 
VARY- See Also:
- Constant Field Values
 
- 
WWW_AUTHENTICATE- See Also:
- Constant Field Values
 
- 
COOKIESee IETF RFC 2109.- See Also:
- Constant Field Values
 
- 
SET_COOKIESee IETF RFC 2109.- See Also:
- Constant Field Values
 
- 
LAST_EVENT_ID_HEADER"Last-Event-ID"HTTP request header name as defined by SSE specification.- Since:
- 2.1
- See Also:
- Constant Field Values
 
 
- 
- 
Method Details- 
getRequestHeaderGet the values of a HTTP request header. The returned List is read-only. This is a shortcut forgetRequestHeaders().get(name).- Parameters:
- name- the header name, case insensitive.
- Returns:
- a read-only list of header values.
- Throws:
- IllegalStateException- if called outside the scope of a request.
 
- 
getHeaderStringGet a HTTP header as a single string value. Each single header value is converted to String using aRuntimeDelegate.HeaderDelegateif one is available viaRuntimeDelegate.createHeaderDelegate(java.lang.Class)for the header value class or using itstoStringmethod if a header delegate is not available.- Parameters:
- name- the HTTP header.
- Returns:
- the HTTP header value. If the HTTP header is not present then nullis 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)
 
- 
getRequestHeadersMultivaluedMap<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 returnsnull.- Returns:
- a read-only map of header names and values.
- Throws:
- IllegalStateException- if called outside the scope of a request.
 
- 
getAcceptableMediaTypesGet a list of media types that are acceptable for the response. If no acceptable media types are specified, a read-only list containing a singlewildcard media typeinstance is returned.- Returns:
- a read-only list of requested response media types sorted according to their q-value, with highest preference first.
- Throws:
- IllegalStateException- if called outside the scope of a request.
 
- 
getAcceptableLanguagesGet a list of languages that are acceptable for the response. If no acceptable languages are specified, a read-only list containing a single wildcardLocaleinstance (with language field set to "*") is returned.- Returns:
- a read-only list of acceptable languages sorted according to their q-value, with highest preference first.
- Throws:
- IllegalStateException- if called outside the scope of a request.
 
- 
getMediaTypeMediaType getMediaType()Get the media type of the request entity.- Returns:
- the media type or nullif there is no request entity.
- Throws:
- IllegalStateException- if called outside the scope of a request.
 
- 
getLanguageLocale getLanguage()Get the language of the request entity.- Returns:
- the language of the entity or nullif not specified.
- Throws:
- IllegalStateException- if called outside the scope of a request.
 
- 
getCookiesGet any cookies that accompanied the request.- Returns:
- a read-only map of cookie name (String) to Cookie.
- Throws:
- IllegalStateException- if called outside the scope of a request
 
- 
getDateDate getDate()Get message date.- Returns:
- the message date, otherwise nullif not present.
- Since:
- 2.0
 
- 
getLengthint getLength()Get Content-Length value.- Returns:
- Content-Length as integer if present and valid number. In other cases returns -1.
- Since:
- 2.0
 
 
-