rabbit.httpio
Class HttpHeaderParser

java.lang.Object
  extended by rabbit.httpio.HttpHeaderParser
All Implemented Interfaces:
LineListener

public class HttpHeaderParser
extends Object
implements LineListener

A parser of http headers

Author:
Robert Olofsson

Constructor Summary
HttpHeaderParser(boolean request, boolean strictHttp)
          Create a new HttpHeaderParser
 
Method Summary
 HttpHeader getHeader()
          Get the current header
 boolean handleBuffer(ByteBuffer buffer)
          Read the data from the buffer and try to build a http header.
 void lineRead(String line)
          Handle a newly read line.
 void reset()
          Restore the parser to its initial state
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpHeaderParser

public HttpHeaderParser(boolean request,
                        boolean strictHttp)
Create a new HttpHeaderParser

Parameters:
request - if true try to read a request, if false try to read a response
strictHttp - if true http headers will be strictly parsed, if false http newlines may be single \n
Method Detail

reset

public void reset()
Restore the parser to its initial state


getHeader

public HttpHeader getHeader()
Get the current header

Returns:
the header as it looks at this moment

handleBuffer

public boolean handleBuffer(ByteBuffer buffer)
Read the data from the buffer and try to build a http header.

Parameters:
buffer - the ByteBuffer to parse
Returns:
true if a full header was read, false if more data is needed.

lineRead

public void lineRead(String line)
Handle a newly read line.

Specified by:
lineRead in interface LineListener
Parameters:
line - the line of text that have been read.