rabbit.httpio
Class HttpHeaderReader

java.lang.Object
  extended by rabbit.httpio.BaseSocketHandler
      extended by rabbit.httpio.HttpHeaderReader
All Implemented Interfaces:
ReadHandler, SocketChannelHandler

public class HttpHeaderReader
extends BaseSocketHandler
implements ReadHandler

A handler that reads http headers

Author:
Robert Olofsson

Constructor Summary
HttpHeaderReader(SocketChannel channel, BufferHandle bh, NioHandler nioHandler, TrafficLogger tl, boolean request, boolean strictHttp, HttpHeaderListener reader)
           
 
Method Summary
 void closed()
          Does nothing by default
 String getDescription()
           
 void read()
           
 void readHeader()
          Try to read a http header
 void timeout()
          Does nothing by default
 
Methods inherited from class rabbit.httpio.BaseSocketHandler
closeDown, getBuffer, getBufferHandle, getChannel, getLargeBuffer, getLogger, getTimeout, isUsingSmallBuffer, releaseBuffer, useSeparateThread, waitForRead, waitForWrite
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.khelekore.rnio.SocketChannelHandler
getTimeout, useSeparateThread
 

Constructor Detail

HttpHeaderReader

public HttpHeaderReader(SocketChannel channel,
                        BufferHandle bh,
                        NioHandler nioHandler,
                        TrafficLogger tl,
                        boolean request,
                        boolean strictHttp,
                        HttpHeaderListener reader)
Parameters:
channel - the SocketChannel to read from
bh - the BufferHandle to use to get ByteBuffers
nioHandler - the NioHandler to use to wait for more data
tl - the TrafficLogger to update with network read Statistics
request - true if a request is read, false if a response is read. Servers may respond without header (HTTP/0.9) so try to handle that.
strictHttp - if true http headers will be strictly parsed, if false http newlines may be single \n
reader - the listener for http headers
Method Detail

readHeader

public void readHeader()
                throws IOException
Try to read a http header

Throws:
IOException - if a header can not be parsed

getDescription

public String getDescription()
Specified by:
getDescription in interface SocketChannelHandler
Overrides:
getDescription in class BaseSocketHandler

closed

public void closed()
Description copied from class: BaseSocketHandler
Does nothing by default

Specified by:
closed in interface SocketChannelHandler
Overrides:
closed in class BaseSocketHandler

timeout

public void timeout()
Description copied from class: BaseSocketHandler
Does nothing by default

Specified by:
timeout in interface SocketChannelHandler
Overrides:
timeout in class BaseSocketHandler

read

public void read()
Specified by:
read in interface ReadHandler