rabbit.httpio
Class LineReader

java.lang.Object
  extended by rabbit.httpio.LineReader

public class LineReader
extends Object

A class that reads lines from a ByteBuffer.

Author:
Robert Olofsson

Constructor Summary
LineReader(boolean strictHttp)
          Create a new LineReader.
 
Method Summary
 void readLine(ByteBuffer buffer, LineListener listener)
          Try to read a line.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LineReader

public LineReader(boolean strictHttp)
Create a new LineReader.

There are many web servers on the internet that still use broken HTTP and send simple \n\n for end of header. Be careful of how you set the strict flag.

Parameters:
strictHttp - if true only CRLF will be accepted as newlines, if false single LF will also be accepted.
Method Detail

readLine

public void readLine(ByteBuffer buffer,
                     LineListener listener)
              throws IOException
Try to read a line. If a line ending is found the buffers mark is set to the next position.

Parameters:
buffer - the ByteBuffer to read bytes from.
listener - the line listener.
Throws:
IOException