-
public interface HttpHeaders
An injectable interface that provides access to HTTP header information. All methods throwIllegalStateException
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
Fields Modifier and Type Field and Description static String
ACCEPT
static String
ACCEPT_CHARSET
static String
ACCEPT_ENCODING
static String
ACCEPT_LANGUAGE
static String
ALLOW
static String
AUTHORIZATION
static String
CACHE_CONTROL
static String
CONTENT_DISPOSITION
See IETF RFC-2183.static String
CONTENT_ENCODING
static String
CONTENT_ID
See IETF RFC-2392.static String
CONTENT_LANGUAGE
static String
CONTENT_LENGTH
static String
CONTENT_LOCATION
static String
CONTENT_TYPE
static String
COOKIE
See IETF RFC 2109.static String
DATE
static String
ETAG
static String
EXPIRES
static String
HOST
static String
IF_MATCH
static String
IF_MODIFIED_SINCE
static String
IF_NONE_MATCH
static String
IF_UNMODIFIED_SINCE
static String
LAST_MODIFIED
static String
LINK
static String
LOCATION
static String
RETRY_AFTER
static String
SET_COOKIE
See IETF RFC 2109.static String
USER_AGENT
static String
VARY
static String
WWW_AUTHENTICATE
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and 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.Date
getDate()
Get message date.String
getHeaderString(String name)
Get a HTTP header as a single string value.Locale
getLanguage()
Get the language of the request entity.int
getLength()
Get Content-Length value.MediaType
getMediaType()
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 Detail
-
ACCEPT
static final String ACCEPT
- See Also:
- Constant Field Values
-
ACCEPT_CHARSET
static final String ACCEPT_CHARSET
- See Also:
- Constant Field Values
-
ACCEPT_ENCODING
static final String ACCEPT_ENCODING
- See Also:
- Constant Field Values
-
ACCEPT_LANGUAGE
static final String ACCEPT_LANGUAGE
- See Also:
- Constant Field Values
-
ALLOW
static final String ALLOW
- See Also:
- Constant Field Values
-
AUTHORIZATION
static final String AUTHORIZATION
- See Also:
- Constant Field Values
-
CACHE_CONTROL
static final String CACHE_CONTROL
- See Also:
- Constant Field Values
-
CONTENT_DISPOSITION
static final String CONTENT_DISPOSITION
See IETF RFC-2183.- See Also:
- Constant Field Values
-
CONTENT_ENCODING
static final String CONTENT_ENCODING
- See Also:
- Constant Field Values
-
CONTENT_ID
static final String CONTENT_ID
See IETF RFC-2392.- See Also:
- Constant Field Values
-
CONTENT_LANGUAGE
static final String CONTENT_LANGUAGE
- See Also:
- Constant Field Values
-
CONTENT_LENGTH
static final String CONTENT_LENGTH
- See Also:
- Constant Field Values
-
CONTENT_LOCATION
static final String CONTENT_LOCATION
- See Also:
- Constant Field Values
-
CONTENT_TYPE
static final String CONTENT_TYPE
- See Also:
- Constant Field Values
-
DATE
static final String DATE
- See Also:
- Constant Field Values
-
ETAG
static final String ETAG
- See Also:
- Constant Field Values
-
EXPIRES
static final String EXPIRES
- See Also:
- Constant Field Values
-
HOST
static final String HOST
- See Also:
- Constant Field Values
-
IF_MATCH
static final String IF_MATCH
- See Also:
- Constant Field Values
-
IF_MODIFIED_SINCE
static final String IF_MODIFIED_SINCE
- See Also:
- Constant Field Values
-
IF_NONE_MATCH
static final String IF_NONE_MATCH
- See Also:
- Constant Field Values
-
IF_UNMODIFIED_SINCE
static final String IF_UNMODIFIED_SINCE
- See Also:
- Constant Field Values
-
LAST_MODIFIED
static final String LAST_MODIFIED
- See Also:
- Constant Field Values
-
LOCATION
static final String LOCATION
- See Also:
- Constant Field Values
-
LINK
static final String LINK
- See Also:
- Constant Field Values
-
RETRY_AFTER
static final String RETRY_AFTER
- See Also:
- Constant Field Values
-
USER_AGENT
static final String USER_AGENT
- See Also:
- Constant Field Values
-
VARY
static final String VARY
- See Also:
- Constant Field Values
-
WWW_AUTHENTICATE
static final String WWW_AUTHENTICATE
- See Also:
- Constant Field Values
-
COOKIE
static final String COOKIE
See IETF RFC 2109.- See Also:
- Constant Field Values
-
SET_COOKIE
static final String SET_COOKIE
See IETF RFC 2109.- See Also:
- Constant Field Values
-
-
Method Detail
-
getRequestHeader
List<String> getRequestHeader(String name)
Get 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.
-
getHeaderString
String getHeaderString(String name)
Get a HTTP header as a single string value. Each single header value is converted to String using aRuntimeDelegate.HeaderDelegate
if one is available viaRuntimeDelegate.createHeaderDelegate(java.lang.Class)
for the header value class or using itstoString
method 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
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)
-
getRequestHeaders
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 returnsnull
.- Returns:
- a read-only map of header names and values.
- Throws:
IllegalStateException
- if called outside the scope of a request.
-
getAcceptableMediaTypes
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 singlewildcard media type
instance 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.
-
getAcceptableLanguages
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 wildcardLocale
instance (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.
-
getMediaType
MediaType getMediaType()
Get the media type of the request entity.- Returns:
- the media type or
null
if there is no request entity. - Throws:
IllegalStateException
- if called outside the scope of a request.
-
getLanguage
Locale getLanguage()
Get the language of the request entity.- Returns:
- the language of the entity or
null
if not specified. - Throws:
IllegalStateException
- if called outside the scope of a request.
-
getCookies
Map<String,Cookie> getCookies()
Get 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
-
getDate
Date getDate()
Get message date.- Returns:
- the message date, otherwise
null
if not present. - Since:
- 2.0
-
getLength
int getLength()
Get Content-Length value.- Returns:
- Content-Length as integer if present and valid number. In other cases returns -1.
- Since:
- 2.0
-
-
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 11/06/2005 gemaakt, de laatste keer de 18/08/2025 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-javaee-rf-javax/ws/rs/core/HttpHeaders.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur van deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.