rabbit.httpio
Class HttpHeaderParser

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

public class HttpHeaderParser
extends java.lang.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(java.nio.ByteBuffer buffer)
          Read the data from the buffer and try to build a http header.
 void lineRead(java.lang.String line)
          Handle a newly read line.
 
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

getHeader

public HttpHeader getHeader()
Get the current header

Returns:
the header as it looks at this moment

handleBuffer

public boolean handleBuffer(java.nio.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(java.lang.String line)
Handle a newly read line.

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