Class HttpHandler

  • Direct Known Subclasses:
    HttpHandlerChain, StaticHttpHandlerBase

    public abstract class HttpHandler
    extends Object
    Base class to use when Request/Response/InputStream/OutputStream are needed to implement a customized HTTP container/extension to the HTTP module. The HttpHandler provides developers with a simple and consistent mechanism for extending the functionality of the HTTP WebServer and for bridging existing HTTP based technology like JRuby-on-Rail, Servlet, Bayeux Protocol or any HTTP based protocol.
    Author:
    Jeanfrancois Arcand
    • Constructor Detail

      • HttpHandler

        public HttpHandler()
        Create HttpHandler.
      • HttpHandler

        public HttpHandler​(String name)
        Create HttpHandler with the specific name.
        Parameters:
        name -
    • Method Detail

      • getName

        public String getName()
        Get the HttpHandler name.
        Returns:
        the HttpHandler name.
      • service

        public abstract void service​(Request request,
                                     Response response)
                              throws Exception
        This method should contain the logic for any HTTP extension to the Grizzly HTTP web server.
        Parameters:
        request - The Request
        response - The Response
        Throws:
        Exception
      • destroy

        public void destroy()
        Invoked when the HttpServer and may be overridden by custom implementations to perform implementation specific resource reclaimation tasks. By default, this method does nothing.
      • isAllowCustomStatusMessage

        public boolean isAllowCustomStatusMessage()
        Returns true if custom status messages (reason phrases) are allowed for this response, or false otherwise.
        Returns:
        true if custom status messages (reason phrases) are allowed for this response, or false otherwise.
      • setAllowCustomStatusMessage

        public void setAllowCustomStatusMessage​(boolean allowCustomStatusMessage)
        Sets if the custom status messages (reason phrases) are allowed for this response.
        Parameters:
        allowCustomStatusMessage - true if custom status messages (reason phrases) are allowed for this response, or false otherwise.
      • isAllowEncodedSlash

        public boolean isAllowEncodedSlash()
        Is HTTP URL request allowed to contains encoded slash.
        Returns:
        Is HTTP URL request allowed to contains encoded slash.
      • setAllowEncodedSlash

        public void setAllowEncodedSlash​(boolean allowEncodedSlash)
        When true, URL that contains encoded slash will be allowed. When false, the URL will be rejected and considered as an invalid one.
        Parameters:
        allowEncodedSlash - true
      • getRequestURIEncoding

        public Charset getRequestURIEncoding()
        Get the request URI encoding used by this HttpHandler.
        Returns:
        the request URI encoding used by this HttpHandler.
      • setRequestURIEncoding

        public void setRequestURIEncoding​(Charset requestURIEncoding)
        Set the request URI encoding used by this HttpHandler.
        Parameters:
        requestURIEncoding - the request URI encoding used by this HttpHandler.
      • setRequestURIEncoding

        public void setRequestURIEncoding​(String requestURIEncoding)
        Set the request URI encoding used by this HttpHandler.
        Parameters:
        requestURIEncoding - the request URI encoding used by this HttpHandler.
      • getSessionCookieName

        protected String getSessionCookieName()
        Returns:
        session cookie name, if not set default JSESSIONID name will be used
      • sendAcknowledgment

        protected boolean sendAcknowledgment​(Request request,
                                             Response response)
                                      throws IOException
        The default implementation will acknowledge an Expect: 100-Continue with a response line with the status 100 followed by the final response to this request.
        Parameters:
        request - the Request.
        response - the Response.
        Returns:
        true if request processing should continue after acknowledgment of the expectation, otherwise return false.
        Throws:
        IOException - if an error occurs sending the acknowledgment.
      • setDecodeUrl

        protected void setDecodeUrl​(boolean decodeURL)
        Should this class decode the URL
      • updatePaths

        protected static void updatePaths​(Request request,
                                          MappingData mappingData)
        Utility method to update Request path values.
        Parameters:
        request -
        mappingData -
      • setDispatcherHelper

        protected void setDispatcherHelper​(DispatcherHelper dispatcherHelper)