org.jwall.web.http.nio
Class HttpRequestChannel

java.lang.Object
  extended by org.jwall.web.http.nio.HttpMessageChannel<HttpRequest>
      extended by org.jwall.web.http.nio.HttpRequestChannel

public class HttpRequestChannel
extends HttpMessageChannel<HttpRequest>

$Id: HttpRequestStream.java 79 2007-10-22 23:43:37Z chris $

This class implements a reader which reads from the input-stream and parses http-requests. The requests are queued and can be fetched by getRequest().

Author:
chris@jwall.org

Field Summary
static org.slf4j.Logger log
           
static String TIMEOUT_PROPERTY
           
 
Fields inherited from class org.jwall.web.http.nio.HttpMessageChannel
STATE_READING_BODY, STATE_READING_HEADER
 
Constructor Summary
HttpRequestChannel(InputStream in)
           
HttpRequestChannel(ReadableByteChannel in)
          Creates a HttpRequestStream which parses requests from the given input-stream.
 
Method Summary
 void close()
          This method closes the message-channel and also closes the underlying byte-channel.
 int getNumberOfRequests()
           
 HttpRequest readMessage()
           
 HttpRequest readRequest()
          This method returns the next complete request in the input-stream.
 String toString()
           
 
Methods inherited from class org.jwall.web.http.nio.HttpMessageChannel
getState, getTimeout, readBody, readHeader, setTimeout, timedOut, touch
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TIMEOUT_PROPERTY

public static final String TIMEOUT_PROPERTY
See Also:
Constant Field Values

log

public static org.slf4j.Logger log
Constructor Detail

HttpRequestChannel

public HttpRequestChannel(ReadableByteChannel in)
                   throws IOException
Creates a HttpRequestStream which parses requests from the given input-stream. The cid-string is used for logging.

Parameters:
in -
Throws:
IOException

HttpRequestChannel

public HttpRequestChannel(InputStream in)
                   throws IOException
Throws:
IOException
Method Detail

readMessage

public HttpRequest readMessage()
                        throws TimeOutException,
                               IOException,
                               ProtocolException
Specified by:
readMessage in class HttpMessageChannel<HttpRequest>
Throws:
TimeOutException
IOException
ProtocolException

readRequest

public HttpRequest readRequest()
                        throws TimeOutException,
                               IOException,
                               ProtocolException
This method returns the next complete request in the input-stream. The result is an array which has size 1 most of the time, but can be of size 2, if the request has a body. In this case, the body is returned as the second element in the array.

Returns:
A string array consisting of a request-header and possibly a request-body element.
Throws:
TimeOutException
IOException
ProtocolException

close

public void close()
           throws IOException
Description copied from class: HttpMessageChannel
This method closes the message-channel and also closes the underlying byte-channel.

Overrides:
close in class HttpMessageChannel<HttpRequest>
Throws:
IOException - In case closing the underlying byte-channel resulted in an I/O error.

getNumberOfRequests

public int getNumberOfRequests()

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2012 jwall.org. All Rights Reserved.