Class HTTPHandler

  extended bySK.gnome.dwarf.GenericService
      extended bySK.gnome.dwarf.thread.ThreadService
          extended bySK.gnome.dwarf.thread.Handler
              extended bySK.gnome.dwarf.tcpip.TCPHandler
                  extended bySK.gnome.dwarf.http.HTTPHandler
All Implemented Interfaces:
SK.gnome.dwarf.Reportable, java.lang.Runnable, SK.gnome.dwarf.Service, SK.gnome.dwarf.Stoppable

public class HTTPHandler
extends SK.gnome.dwarf.tcpip.TCPHandler
implements SK.gnome.dwarf.Reportable

This class handles the HTTP connections.

The handler is able to automatically invoke the HTTP authentication methods, and it handles also displaying of custom error pages, defined by the web applications. It provides a detailed report via the report() method.

HTTPHandler must be added to the HTTPServer object.

Field Summary
Fields inherited from class SK.gnome.dwarf.thread.ThreadService
daemon, thread
Fields inherited from class SK.gnome.dwarf.GenericService
initParameters, parent
Fields inherited from interface SK.gnome.dwarf.Service
Constructor Summary
HTTPHandler(java.lang.String name)
          Creates a new HTTPHandler.
Method Summary
protected  int getShutdownTimeout()
          Returns the shutdown timeout.
protected  void handle( socket)
          Handles the HTTP connection.
 void init(SK.gnome.dwarf.Server parent)
          Initializes the service.
 java.lang.String report()
          Returns the service report.
Methods inherited from class SK.gnome.dwarf.tcpip.TCPHandler
Methods inherited from class SK.gnome.dwarf.thread.Handler
enableThread, loop, start
Methods inherited from class SK.gnome.dwarf.thread.ThreadService
finish, run, setDaemon, shutdown, stop
Methods inherited from class SK.gnome.dwarf.GenericService
getAuthenticator, getAuthFacility, getFullName, getInitParameter, getInitParameterNames, getLogFacility, getLogger, getName, getParameters, getPrincipal, getState, log, log, login, logout, setAuthFacility, setInitParameters, setLogFacility, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail


public HTTPHandler(java.lang.String name)
Creates a new HTTPHandler.

Method Detail


public void init(SK.gnome.dwarf.Server parent)
          throws SK.gnome.dwarf.ServiceException
Initializes the service.

Specified by:
init in interface SK.gnome.dwarf.Service


protected void handle( socket)
Handles the HTTP connection.

It reads the information from the client socket and creates a new Request object as well as the Response object. It then passes them to the RequestDispatcher obtained from the request for processing. If an error occured during the request/response life-cycle, a detailed message including the stack trace can be sent to the client if allowed by the server configuration.

Persistent connections are handled automatically if enabled and can be adjusted to control the server performance. See the HTTPParameters class for more information about the persistence-related parameters.

The report() method returns a detailed information about the current handler's activity.


protected int getShutdownTimeout()
Returns the shutdown timeout.

It returns the Constants.DEFAULT_SHUTDOWN_TIMEOUT value if the persistent connections are not enabled, or the value returned from the getKeepAliveTimeout method in the opposit case.


public java.lang.String report()
Returns the service report.

The first letter of each report string is 'R' for reading a new request, 'K' for processing a persistent (keep-alive) connection, 'C' for processing a non-persistent connection, and '_' indicates that the handler is idle. The initial letter is followed by the client's IP address and a detailed information about the request, if available.

Examples of the report strings:

 _                                         handler is idle, i.e. it waits until a 
                                           connection is available for processing

 R                             handler reads a new client request 

 K                             handler reads a new client request from a 
                                           persistent connection

 C GET /logo.gif HTTP/1.0      handler processes a client request 

 x                                         handler is currently stopped 

Specified by:
report in interface SK.gnome.dwarf.Reportable

Copyright (c) 1999-2005, Gnome Ltd. All rights reserved.