public class HttpListener extends java.lang.Object implements Listener, java.lang.Runnable
Modifier and Type | Field and Description |
---|---|
protected static int |
BACKLOG_COUNT |
protected static int |
CONNECTION_TIMEOUT |
protected static boolean |
DEFAULT_HNL |
protected boolean |
doHostnameLookups |
protected HostGroup |
hostGroup |
protected boolean |
interrupted |
protected static int |
KEEP_ALIVE_SLEEP |
protected static int |
KEEP_ALIVE_SLEEP_MAX |
protected static int |
KEEP_ALIVE_TIMEOUT |
protected java.lang.String |
listenAddress |
protected static int |
LISTENER_TIMEOUT |
protected int |
listenPort |
protected ObjectPool |
objectPool |
Modifier | Constructor and Description |
---|---|
protected |
HttpListener() |
|
HttpListener(java.util.Map args,
ObjectPool objectPool,
HostGroup hostGroup)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
allocateRequestResponse(java.net.Socket socket,
java.io.InputStream inSocket,
java.io.OutputStream outSocket,
RequestHandlerThread handler,
boolean iAmFirst)
Called by the request handler thread, because it needs specific setup
code for this connection's protocol (ie construction of request/response
objects, in/out streams, etc).
|
void |
deallocateRequestResponse(RequestHandlerThread handler,
WinstoneRequest req,
WinstoneResponse rsp,
WinstoneInputStream inData,
WinstoneOutputStream outData)
Called by the request handler thread, because it needs specific shutdown
code for this connection's protocol (ie releasing input/output streams,
etc).
|
void |
destroy()
Interrupts the listener thread.
|
protected java.lang.String |
getConnectorName()
The name to use when getting properties - this is just so that we can
override for the SSL connector.
|
protected java.lang.String |
getConnectorScheme() |
protected int |
getDefaultPort()
The default port to use - this is just so that we can override for the
SSL connector.
|
protected java.net.ServerSocket |
getServerSocket()
Gets a server socket - this is mostly for the purpose of allowing an
override in the SSL connector.
|
void |
parseHeaders(WinstoneRequest req,
WinstoneInputStream inData)
Parse the incoming stream into a list of headers (stopping at the first
blank line), then call the parseHeaders(req, list) method on that list.
|
protected void |
parseSocketInfo(java.net.Socket socket,
WinstoneRequest req) |
java.lang.String |
parseURI(RequestHandlerThread handler,
WinstoneRequest req,
WinstoneResponse rsp,
WinstoneInputStream inData,
java.net.Socket socket,
boolean iAmFirst)
Called by the request handler thread, because it needs specific shutdown
code for this connection's protocol if the keep-alive period expires (ie
closing sockets, etc).The iAmFirst variable identifies whether or
not this is the initial request on on this socket (ie a keep alive or
a first-time accept)
|
boolean |
processKeepAlive(WinstoneRequest request,
WinstoneResponse response,
java.io.InputStream inSocket)
Tries to wait for extra requests on the same socket.
|
void |
releaseSocket(java.net.Socket socket,
java.io.InputStream inSocket,
java.io.OutputStream outSocket)
Called by the request handler thread, because it needs specific shutdown
code for this connection's protocol if the keep-alive period expires (ie
closing sockets, etc).
|
void |
run()
The main run method.
|
boolean |
start()
After the listener is loaded and initialized, this starts the thread
|
protected static int LISTENER_TIMEOUT
protected static int CONNECTION_TIMEOUT
protected static int BACKLOG_COUNT
protected static boolean DEFAULT_HNL
protected static int KEEP_ALIVE_TIMEOUT
protected static int KEEP_ALIVE_SLEEP
protected static int KEEP_ALIVE_SLEEP_MAX
protected HostGroup hostGroup
protected ObjectPool objectPool
protected boolean doHostnameLookups
protected int listenPort
protected java.lang.String listenAddress
protected boolean interrupted
protected HttpListener()
public HttpListener(java.util.Map args, ObjectPool objectPool, HostGroup hostGroup)
public boolean start() throws java.io.IOException
Listener
protected int getDefaultPort()
protected java.lang.String getConnectorName()
protected java.lang.String getConnectorScheme()
protected java.net.ServerSocket getServerSocket() throws java.io.IOException
java.io.IOException
public void run()
run
in interface java.lang.Runnable
public void destroy()
public void allocateRequestResponse(java.net.Socket socket, java.io.InputStream inSocket, java.io.OutputStream outSocket, RequestHandlerThread handler, boolean iAmFirst) throws java.net.SocketException, java.io.IOException
allocateRequestResponse
in interface Listener
java.net.SocketException
java.io.IOException
public void deallocateRequestResponse(RequestHandlerThread handler, WinstoneRequest req, WinstoneResponse rsp, WinstoneInputStream inData, WinstoneOutputStream outData)
deallocateRequestResponse
in interface Listener
public java.lang.String parseURI(RequestHandlerThread handler, WinstoneRequest req, WinstoneResponse rsp, WinstoneInputStream inData, java.net.Socket socket, boolean iAmFirst) throws java.io.IOException
Listener
public void releaseSocket(java.net.Socket socket, java.io.InputStream inSocket, java.io.OutputStream outSocket) throws java.io.IOException
releaseSocket
in interface Listener
java.io.IOException
protected void parseSocketInfo(java.net.Socket socket, WinstoneRequest req) throws java.io.IOException
java.io.IOException
public boolean processKeepAlive(WinstoneRequest request, WinstoneResponse response, java.io.InputStream inSocket)
processKeepAlive
in interface Listener
public void parseHeaders(WinstoneRequest req, WinstoneInputStream inData) throws java.io.IOException
java.io.IOException
Copyright © 2012. All Rights Reserved.