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
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1">HTTP/1.1 documentation}.
    static final String
    See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.2">HTTP/1.1 documentation}.
    static final String
    See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.3">HTTP/1.1 documentation}.
    static final String
    See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4">HTTP/1.1 documentation}.
    static final String
    See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.7">HTTP/1.1 documentation}.
    static final String
    See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.8">HTTP/1.1 documentation}.
    static final String
    See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9">HTTP/1.1 documentation}.
    static final String
    See {@link <a href="http://tools.ietf.org/html/rfc2183">IETF RFC-2183}.
    static final String
    See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11">HTTP/1.1 documentation}.
    static final String
    See {@link <a href="http://tools.ietf.org/html/rfc2392">IETF RFC-2392}.
    static final String
    See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.12">HTTP/1.1 documentation}.
    static final String
    See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13">HTTP/1.1 documentation}.
    static final String
    See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.14">HTTP/1.1 documentation}.
    static final String
    See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17">HTTP/1.1 documentation}.
    static final String
    See {@link <a href="http://www.ietf.org/rfc/rfc2109.txt">IETF RFC 2109}.
    static final String
    See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.18">HTTP/1.1 documentation}.
    static final String
    See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.19">HTTP/1.1 documentation}.
    static final String
    See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.21">HTTP/1.1 documentation}.
    static final String
    See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.23">HTTP/1.1 documentation}.
    static final String
    See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.24">HTTP/1.1 documentation}.
    static final String
    See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.25">HTTP/1.1 documentation}.
    static final String
    See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.26">HTTP/1.1 documentation}.
    static final String
    See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.28">HTTP/1.1 documentation}.
    static final String
    See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.29">HTTP/1.1 documentation}.
    static final String
    See {@link <a href="http://tools.ietf.org/html/rfc5988#page-6">Web Linking (IETF RFC-5988) documentation}.
    static final String
    See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.30">HTTP/1.1 documentation}.
    static final String
    See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.37">HTTP/1.1 documentation}.
    static final String
    See {@link <a href="http://www.ietf.org/rfc/rfc2109.txt">IETF RFC 2109}.
    static final String
    See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43">HTTP/1.1 documentation}.
    static final String
    See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.44">HTTP/1.1 documentation}.
    static final String
    See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.47">HTTP/1.1 documentation}.
  • Method Summary

    Modifier and Type
    Method
    Description
    Get a list of languages that are acceptable for the response.
    Get a list of media types that are acceptable for the response.
    Get any cookies that accompanied the request.
    Get message date.
    Get a HTTP header as a single string value.
    Get the language of the request entity.
    int
    Get Content-Length value.
    Get the media type of the request entity.
    Get the values of a HTTP request header.
    Get the values of HTTP request headers.
  • Field Details

    • ACCEPT

      static final String ACCEPT
      See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1">HTTP/1.1 documentation}.
      See Also:
    • ACCEPT_CHARSET

      static final String ACCEPT_CHARSET
      See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.2">HTTP/1.1 documentation}.
      See Also:
    • ACCEPT_ENCODING

      static final String ACCEPT_ENCODING
      See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.3">HTTP/1.1 documentation}.
      See Also:
    • ACCEPT_LANGUAGE

      static final String ACCEPT_LANGUAGE
      See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4">HTTP/1.1 documentation}.
      See Also:
    • ALLOW

      static final String ALLOW
      See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.7">HTTP/1.1 documentation}.
      See Also:
    • AUTHORIZATION

      static final String AUTHORIZATION
      See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.8">HTTP/1.1 documentation}.
      See Also:
    • CACHE_CONTROL

      static final String CACHE_CONTROL
      See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9">HTTP/1.1 documentation}.
      See Also:
    • CONTENT_DISPOSITION

      static final String CONTENT_DISPOSITION
      See {@link <a href="http://tools.ietf.org/html/rfc2183">IETF RFC-2183}.
      See Also:
    • CONTENT_ENCODING

      static final String CONTENT_ENCODING
      See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11">HTTP/1.1 documentation}.
      See Also:
    • CONTENT_ID

      static final String CONTENT_ID
      See {@link <a href="http://tools.ietf.org/html/rfc2392">IETF RFC-2392}.
      See Also:
    • CONTENT_LANGUAGE

      static final String CONTENT_LANGUAGE
      See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.12">HTTP/1.1 documentation}.
      See Also:
    • CONTENT_LENGTH

      static final String CONTENT_LENGTH
      See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13">HTTP/1.1 documentation}.
      See Also:
    • CONTENT_LOCATION

      static final String CONTENT_LOCATION
      See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.14">HTTP/1.1 documentation}.
      See Also:
    • CONTENT_TYPE

      static final String CONTENT_TYPE
      See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17">HTTP/1.1 documentation}.
      See Also:
    • DATE

      static final String DATE
      See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.18">HTTP/1.1 documentation}.
      See Also:
    • ETAG

      static final String ETAG
      See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.19">HTTP/1.1 documentation}.
      See Also:
    • EXPIRES

      static final String EXPIRES
      See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.21">HTTP/1.1 documentation}.
      See Also:
    • HOST

      static final String HOST
      See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.23">HTTP/1.1 documentation}.
      See Also:
    • IF_MATCH

      static final String IF_MATCH
      See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.24">HTTP/1.1 documentation}.
      See Also:
    • IF_MODIFIED_SINCE

      static final String IF_MODIFIED_SINCE
      See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.25">HTTP/1.1 documentation}.
      See Also:
    • IF_NONE_MATCH

      static final String IF_NONE_MATCH
      See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.26">HTTP/1.1 documentation}.
      See Also:
    • IF_UNMODIFIED_SINCE

      static final String IF_UNMODIFIED_SINCE
      See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.28">HTTP/1.1 documentation}.
      See Also:
    • LAST_MODIFIED

      static final String LAST_MODIFIED
      See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.29">HTTP/1.1 documentation}.
      See Also:
    • LOCATION

      static final String LOCATION
      See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.30">HTTP/1.1 documentation}.
      See Also:
    • RETRY_AFTER

      static final String RETRY_AFTER
      See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.37">HTTP/1.1 documentation}.
      See Also:
    • USER_AGENT

      static final String USER_AGENT
      See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43">HTTP/1.1 documentation}.
      See Also:
    • VARY

      static final String VARY
      See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.44">HTTP/1.1 documentation}.
      See Also:
    • WWW_AUTHENTICATE

      static final String WWW_AUTHENTICATE
      See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.47">HTTP/1.1 documentation}.
      See Also:
  • Method Details

    • getRequestHeader

      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 - 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 a RuntimeDelegate.HeaderDelegate if one is available via RuntimeDelegate.createHeaderDelegate(java.lang.Class) for the header value class or using its toString 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:
    • 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 returns null.
      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 single wildcard 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 wildcard Locale 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