public final class HttpParser extends Object
HTTP-messages
.Modifier and Type | Field and Description |
---|---|
private static Charset |
CHARSET_US_ASCII
the default encoding
|
private static CharFilter |
TOKEN_FILTER
char-filter for a token as defined by the HTTP specification
|
Modifier | Constructor and Description |
---|---|
private |
HttpParser()
The constructor.
|
Modifier and Type | Method and Description |
---|---|
private static String |
parseLine(InputStream stream,
byte[] buffer,
Charset charset)
This method parses a single line of an HTTP header from the given
stream . |
private static void |
parseProperties(InputStream stream,
HttpMessage message,
Charset charset,
byte[] buffer)
This method parses the HTTP header properties from the given
stream . |
static void |
parseRequest(InputStream stream,
HttpRequest request)
This method parses the HTTP-header from the given
stream and applies all information to the given
request . |
static void |
parseRequest(InputStream stream,
HttpRequest request,
Charset charset)
This method parses the HTTP-header from the given
stream and applies all information to the given
request . |
private static final Charset CHARSET_US_ASCII
private static final CharFilter TOKEN_FILTER
private static String parseLine(InputStream stream, byte[] buffer, Charset charset) throws IOException
stream
. It (re)uses the given
buffer
to cache bytes while reading. To convert the read bytes to a string the given charset
is
used.stream
- is the input stream to read from.buffer
- is where the bytes can be cached.charset
- is used to convert the bytes to a string.null
if the stream
is already at EOF.IOException
- if the operation failes with an I/O problem.private static void parseProperties(InputStream stream, HttpMessage message, Charset charset, byte[] buffer) throws IOException
stream
. This method should be called after the
first line has been read and an HTTP-version greator or equal to "1.0" has been detected.stream
- is the stream to read from.message
- is the HTTP-message where to set
the parsed
properties.charset
- is the charset used to parse the properties.buffer
- is a buffer used to cache bytes.IOException
- if the operation failes with an I/O problem.public static void parseRequest(InputStream stream, HttpRequest request) throws IOException
stream
and applies all information to the given
request
. After this method has been called, the given stream
is pointing to the beginning of the
HTTP-body (or EOF if empty). stream
- is the input-stream to read the header from. Only the header is read so the stream is NOT closed by
this method.request
- is where to apply the parsed information to. Simply supply a new instance.IOException
- if the operation failes with an I/O problem.public static void parseRequest(InputStream stream, HttpRequest request, Charset charset) throws IOException
stream
and applies all information to the given
request
. After this method has been called, the given stream
is pointing to the beginning of the
HTTP-body (or EOF if empty). stream
- is the input-stream to read the header from. Only the header is read so the stream is NOT closed by
this method.request
- is where to apply the parsed information to. Simply supply a new instance.charset
- is the charset used to convert the read bytes to strings.IOException
- if the operation failes with an I/O problem.Copyright © 2001–2016 mmm-Team. All rights reserved.