net.officefloor.plugin.socket.server.http.parse.impl
Class HttpRequestParserImpl

java.lang.Object
  extended by net.officefloor.plugin.socket.server.http.parse.impl.HttpRequestParserImpl
All Implemented Interfaces:
HttpRequestParser

public class HttpRequestParserImpl
extends Object
implements HttpRequestParser

Parser for a HTTP request.

Author:
Daniel Sagenschneider

Field Summary
static Charset US_ASCII
           
 
Constructor Summary
HttpRequestParserImpl(int maxHeaderCount, long maxBodyLength)
          Initiate.
 
Method Summary
 InputBufferStream getBody()
          Obtains the InputBufferStream to the body of the HttpRequest.
 List<HttpHeader> getHeaders()
          Obtains the HttpHeader instances in the order supplied.
 String getHttpVersion()
          Obtains the HTTP version.
 String getMethod()
          Obtains the method.
 String getRequestURI()
          Obtains the request URI.
 boolean parse(InputBufferStream inputBufferStream, char[] tempBuffer)
          Parses the HttpRequest bytes from the InputBufferStream.
 void reset()
          Resets for parsing another HttpRequest.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

US_ASCII

public static final Charset US_ASCII
Constructor Detail

HttpRequestParserImpl

public HttpRequestParserImpl(int maxHeaderCount,
                             long maxBodyLength)
Initiate.

Parameters:
maxHeaderCount - Maximum number of HttpHeader instances for a HttpRequest.
maxBodyLength - Maximum length of the body buffer. Requests with bodies greater that this will fail parsing.
Method Detail

reset

public void reset()
Description copied from interface: HttpRequestParser
Resets for parsing another HttpRequest.

Specified by:
reset in interface HttpRequestParser

parse

public boolean parse(InputBufferStream inputBufferStream,
                     char[] tempBuffer)
              throws IOException,
                     HttpRequestParseException
Description copied from interface: HttpRequestParser
Parses the HttpRequest bytes from the InputBufferStream.

Specified by:
parse in interface HttpRequestParser
Parameters:
inputBufferStream - InputBufferStream containing the data to be parsed for the HttpRequest.
tempBuffer - Temporary char buffer that is used to translate bytes into a String. This allows reducing memory size and creation of arrays. The size of the buffer indicates the maximum size for parts of the HttpRequest (except the body).
Returns:
true if the HttpRequest has been fully parsed. false indicates this method should be called again when further data is available on the InputBufferStream to obtain the full HttpRequest.
Throws:
IOException - If fails to read bytes.
HttpRequestParseException - If failure to parse HttpRequest.

getMethod

public String getMethod()
Description copied from interface: HttpRequestParser
Obtains the method.

Specified by:
getMethod in interface HttpRequestParser
Returns:
Method.

getRequestURI

public String getRequestURI()
Description copied from interface: HttpRequestParser
Obtains the request URI.

Specified by:
getRequestURI in interface HttpRequestParser
Returns:
Request URI.

getHttpVersion

public String getHttpVersion()
Description copied from interface: HttpRequestParser
Obtains the HTTP version.

Specified by:
getHttpVersion in interface HttpRequestParser
Returns:
HTTP version.

getHeaders

public List<HttpHeader> getHeaders()
Description copied from interface: HttpRequestParser
Obtains the HttpHeader instances in the order supplied.

Specified by:
getHeaders in interface HttpRequestParser
Returns:
HttpHeader instances in the order supplied.

getBody

public InputBufferStream getBody()
Description copied from interface: HttpRequestParser
Obtains the InputBufferStream to the body of the HttpRequest.

Specified by:
getBody in interface HttpRequestParser
Returns:
InputBufferStream to the body of the HttpRequest.


Copyright © 2005-2011. All Rights Reserved.