org.mortbay.http
Interface HttpListener
- LifeCycle, Serializable
- AJP13Listener, HostSocketListener, IbmJsseListener, JsseListener, SocketChannelListener, SocketListener, SslListener, SunJsseListener
public interface HttpListener
HTTP Listener.
This interface describes the methods of a generic request listener for the HttpServer.
This class should probably be called HttpConnector, but it's name predates the
EventListener API in java.
Once a HttpListener is started, it is responsible for listening for new
connections. Once a new connection is accepted it should be handled by
creating a HttpConnection instance and calling either the HttpConnection.handle()
or HttpConnection.handleNext() methods from a Thread allocated to that
connection.
$Id: HttpListener.java,v 1.17 2005/03/15 10:03:40 gregwilkins Exp $
ATTRIBUTE
public static final String ATTRIBUTE
customizeRequest
public void customizeRequest(HttpConnection connection,
HttpRequest request)
Customize a request for a listener/connection combination.
This method is called by HttpConnection after a request has been read
from that connection and before processing that request.
Implementations may use this callback to add additional listener
and/or connection specific attributes to the request (eg SSL attributes).
connection
- The connection the request was received on, which must
be a HttpConnection created by this listener.request
- The request to customize.
getBufferReserve
public int getBufferReserve()
Get the size of the header reserve area.
Get the size of the header reserve area within the buffers used
by connections from this listener. The header reserve is space
reserved in the first buffer of a response to allow a HTTP header to
be written in the same packet. The reserve should be large enough to
avoid moving data to fit the header, but not too large as to waste memory.
- The default buffer reserve size in bytes.
getBufferSize
public int getBufferSize()
Get the size of the buffers used by connections from this listener.
- The default buffer size in bytes.
getConfidentialPort
public int getConfidentialPort()
Get the protocol port to use for confidential redirections.
If an CONFIDENTIAL security constraint is not met for a request, the
request is redirected to an confidential port. This port return by this
method is used for that redirection.
- The confidential port. For most implementations this is 443 for https
getConfidentialScheme
public String getConfidentialScheme()
Get the protocol scheme to use for confidential redirections.
If an CONFIDENTIAL security constraint is not met for a request, the
request is redirected to an confidential port. This scheme return by this
method is used for that redirection.
- The confidential scheme. For most implementations this is "https"
getDefaultScheme
public String getDefaultScheme()
Get the default scheme for requests.
If a request is received from a HttpConnection created by this
listener, that does not include a scheme in it's request URL, then
this method is used to determine the protocol scheme most likely used
to connect to this listener.
- The protocol scheme name (eg "http" or "https").
getHost
public String getHost()
Get the host or IP of the interface used by this listener.
- The hostname or IP address of the interface used by this
listeners. If null or "0.0.0.0" then all available interfaces are used
by this listener.
getHttpHandler
public HttpHandler getHttpHandler()
Get an optional HttpHandler for the listener.
If Set, then HttpConnection will pass requests from this listener
to this handler with an empty context path, before passing the
request to the HttpServer. This allows listener specific handling
to be added or even a HttpContext (which is a HttpHandler) to be
bound directly to HttpListener.
getHttpServer
public HttpServer getHttpServer()
Get the HttpServer instance for this HttpListener.
- The HttpServer instance this HttpListener has been added to,
or null if the listener is not added to any HttpServer.
getIntegralPort
public int getIntegralPort()
Get the protocol port to use for integral redirections.
If an INTEGRAL security constraint is not met for a request, the
request is redirected to an integral port. This port return by this
method is used for that redirection.
- The integral port. For most implementations this is 443 for https
getIntegralScheme
public String getIntegralScheme()
Get the protocol scheme to use for integral redirections.
If an INTEGRAL security constraint is not met for a request, the
request is redirected to an integral port. This scheme return by this
method is used for that redirection.
- The integral scheme. For most implementations this is "https"
getPort
public int getPort()
Get the port number of the listener.
- The TCP/IP port number used by this listener.
isConfidential
public boolean isConfidential(HttpConnection connection)
Get the confidential status of a connection.
connection
- The connection to test.
- True of the connection checks the integrity of the data. For
most implementations this is true for https connections.
isIntegral
public boolean isIntegral(HttpConnection connection)
Get the integral status of a connection.
connection
- The connection to test.
- True of the connection checks the integrity of the data. For
most implementations this is true for https connections.
isLowOnResources
public boolean isLowOnResources()
Get the low on resources state of the listener.
For most implementations, Threads are the resource
reported on by this method.
- True if the listener is out of resources.
isOutOfResources
public boolean isOutOfResources()
Get the out of resources state of the listener.
For most implementations, Threads are the resource
reported on by this method.
- True if the listener is out of resources.
persistConnection
public void persistConnection(HttpConnection connection)
Prepare a connection for persistance.
This method is called by the HttpConnection on a persistent connection
after each request has been handled and before starting to read for
the next connection. Implementations may use this callback to change
the parameters or scheduling of the connection.
connection
- The perstent connection, which must be a
HttpConnection created by this listener.
setHost
public void setHost(String host)
throws UnknownHostException
Set the host or IP of the interface used by this listener.
host
- The hostname or IP address of the interface used by this
listeners. If null or "0.0.0.0" then all available interfaces are used
by this listener.
setHttpServer
public void setHttpServer(HttpServer server)
Set the HttpServer instance for this HttpListener.
This method is called by the HttpServer.addListener method.
It should not be called directly.
server
- The HttpServer instance this HttpListener has been added to.
setPort
public void setPort(int port)
Set the port number of the listener.
port
- The TCP/IP port number to be used by this listener.
Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.