public class HttpRequestParserImpl extends Object implements HttpRequestParser
Constructor and Description |
---|
HttpRequestParserImpl(int maxHeaderCount,
int maxTextLength,
long maxEntityLength)
Initiate.
|
Modifier and Type | Method and Description |
---|---|
HttpEntity |
getEntity()
Obtains the
HttpEntity 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.
|
int |
nextByteToParseIndex()
Obtains the index of the next byte to parse from the previous
HttpRequestParser.parse(byte[], int) . |
boolean |
parse(byte[] data,
int startIndex)
Parses the
HttpRequest from the data. |
void |
reset()
Resets for parsing another
HttpRequest . |
public static final Charset US_ASCII
public HttpRequestParserImpl(int maxHeaderCount, int maxTextLength, long maxEntityLength)
maxHeaderCount
- Maximum number of HttpHeader
instances for a
HttpRequest
.maxTextLength
- Maximum number of bytes per TEXT.maxEntityLength
- Maximum length of the entity. Requests with entities greater
than this will fail parsing.public void reset()
HttpRequestParser
HttpRequest
.reset
in interface HttpRequestParser
public int nextByteToParseIndex()
HttpRequestParser
Obtains the index of the next byte to parse from the previous
HttpRequestParser.parse(byte[], int)
.
Should all bytes be consumed this will return -1
. Note that
if HttpRequestParser.parse(byte[], int)
returns false
, this will
always return -1
as all bytes are to be consumed.
nextByteToParseIndex
in interface HttpRequestParser
-1
if all bytes
consumed.public boolean parse(byte[] data, int startIndex) throws IOException, HttpRequestParseException
HttpRequestParser
HttpRequest
from the data.parse
in interface HttpRequestParser
data
- Data to be parsed for the HttpRequest
.startIndex
- Index within the data to start parsing.true
if the HttpRequest
has been fully
parsed. false
indicates this method should be called
again when further data is available to obtain the full
HttpRequest
.IOException
- If fails to read bytes.HttpRequestParseException
- If failure to parse HttpRequest
.HttpRequestParser.nextByteToParseIndex()
public String getMethod()
HttpRequestParser
getMethod
in interface HttpRequestParser
public String getRequestURI()
HttpRequestParser
getRequestURI
in interface HttpRequestParser
public String getHttpVersion()
HttpRequestParser
getHttpVersion
in interface HttpRequestParser
public List<HttpHeader> getHeaders()
HttpRequestParser
HttpHeader
instances in the order supplied.getHeaders
in interface HttpRequestParser
HttpHeader
instances in the order supplied.public HttpEntity getEntity()
HttpRequestParser
HttpEntity
of the HttpRequest
.getEntity
in interface HttpRequestParser
HttpEntity
of the HttpRequest
.Copyright © 2005–2016. All rights reserved.