Class HttpHandler

java.lang.Object
org.glassfish.grizzly.http.server.HttpHandler
Direct Known Subclasses:
HttpHandlerChain, ServletHandler, 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 Details

    • HttpHandler

      public HttpHandler()
      Create HttpHandler.
    • HttpHandler

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

    • 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
    • start

      public void start()
      Called when the HttpHandler's container is started by invoking HttpServer.start(). By default, it does nothing.
    • 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.
    • getRequestExecutorProvider

      public RequestExecutorProvider getRequestExecutorProvider()
      Returns:
      the RequestExecutorProvider responsible for executing user's code in service(org.glassfish.grizzly.http.server.Request, org.glassfish.grizzly.http.server.Response) and notifying ReadHandler, WriteHandler registered by the user.
    • getErrorPageGenerator

      protected ErrorPageGenerator getErrorPageGenerator(Request request)
      Returns the ErrorPageGenerator, that might be used (if an error occurs) during Request processing.
      Parameters:
      request - Request
      Returns:
      the ErrorPageGenerator, that might be used (if an error occurs) during Request processing
    • getSessionCookieName

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

      protected SessionManager getSessionManager(Request request)
      Parameters:
      request - Request
      Returns:
      the SessionManager to be used. null value implies DefaultSessionManager
    • 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)