Class OslcRequests


  • public class OslcRequests
    extends Object
    Provides access to various properties of servlet requests.
    Since:
    1.13.0
    • Method Detail

      • of

        public static OslcRequests of​(HttpServletRequest request)
        Returns an instance that wraps the specified servlet request.
        Parameters:
        request - a servlet request.
        Returns:
        a new OslcRequests instance.
      • isAccepted

        public boolean isAccepted​(MediaType type)
        Determines whether the given media type is compatible with the request Accept header.
        Parameters:
        type - a media type to test.
        Returns:
        true if the request Accept header is compatible with the given type or if the Accept value is empty, false otherwise.
      • getFullUri

        public URI getFullUri()
        Returns the complete URI of the request, which combines the full request path and the query string, if any.
        Returns:
        the complete URI of the request.
      • getLocales

        public List<Locale> getLocales()
        Returns a list of enabled Locale objects indicating, in decreasing order starting with the preferred locale, the locales that are acceptable to the client based on the Accept-Language header and supported by the server.

        The returned list contains the locales requested by client and supported by the server, as defined by the Options.ENABLED_LOCALES property. If the server doesn't support any locale requested by client, this method returns an empty list.

        Returns:
        a list of preferred Locale objects for the client and enabled on server.
        See Also:
        Options.ENABLED_LOCALES
      • wrapper

        public OslcRequests.HttpServletRequestWrapperBuilder wrapper()
        Returns a builder to create a request wrapper, for overriding some properties of the underlying request. Wrapping a request may be useful for example in a filter, for removing or overriding the value of a header, so that successive filters are not aware of the original header the filter has already processed.

        Here's an example of builder usage:

         HttpServletRequest wrapped = OslcRequests.of(request).wrapper().removeHeader(HttpHeaders.AUTHORIZATION).build();
         
        Returns:
        a builder to create a request wrapper
        Since:
        1.14.0.