@Contract(threading=IMMUTABLE) public class BasicLineParser extends Object implements LineParser
Note: This class was created by refactoring parsing code located in various other classes. The author tags from those other classes have been replicated here, although the association with the parsing code taken from there has not been traced.
| Modifier and Type | Field and Description |
|---|---|
static BasicLineParser |
DEFAULT
Deprecated.
(4.3) use
INSTANCE |
static BasicLineParser |
INSTANCE |
protected ProtocolVersion |
protocol
A version of the protocol to parse.
|
| Constructor and Description |
|---|
BasicLineParser()
Creates a new line parser for HTTP.
|
BasicLineParser(ProtocolVersion proto)
Creates a new line parser for the given HTTP-like protocol.
|
| Modifier and Type | Method and Description |
|---|---|
protected ProtocolVersion |
createProtocolVersion(int major,
int minor)
Creates a protocol version.
|
protected RequestLine |
createRequestLine(String method,
String uri,
ProtocolVersion ver)
Instantiates a new request line.
|
protected StatusLine |
createStatusLine(ProtocolVersion ver,
int status,
String reason)
Instantiates a new status line.
|
boolean |
hasProtocolVersion(CharArrayBuffer buffer,
ParserCursor cursor)
Checks whether there likely is a protocol version in a line.
|
Header |
parseHeader(CharArrayBuffer buffer)
Creates a header from a line.
|
static Header |
parseHeader(String value,
LineParser parser) |
ProtocolVersion |
parseProtocolVersion(CharArrayBuffer buffer,
ParserCursor cursor)
Parses the textual representation of a protocol version.
|
static ProtocolVersion |
parseProtocolVersion(String value,
LineParser parser) |
RequestLine |
parseRequestLine(CharArrayBuffer buffer,
ParserCursor cursor)
Parses a request line.
|
static RequestLine |
parseRequestLine(String value,
LineParser parser) |
StatusLine |
parseStatusLine(CharArrayBuffer buffer,
ParserCursor cursor)
Parses a status line.
|
static StatusLine |
parseStatusLine(String value,
LineParser parser) |
protected void |
skipWhitespace(CharArrayBuffer buffer,
ParserCursor cursor)
Helper to skip whitespace.
|
@Deprecated public static final BasicLineParser DEFAULT
INSTANCEBasicLineParser is not a singleton, there can
be many instances of the class itself and of derived classes.
The instance here provides non-customized, default behavior.public static final BasicLineParser INSTANCE
protected final ProtocolVersion protocol
public BasicLineParser(ProtocolVersion proto)
proto - a version of the protocol to parse, or
null for HTTP. The actual version
is not relevant, only the protocol name.public BasicLineParser()
public static ProtocolVersion parseProtocolVersion(String value, LineParser parser) throws ParseException
ParseExceptionpublic ProtocolVersion parseProtocolVersion(CharArrayBuffer buffer, ParserCursor cursor) throws ParseException
LineParserparseProtocolVersion in interface LineParserbuffer - a buffer holding the protocol version to parsecursor - the parser cursor containing the current position and
the bounds within the buffer for the parsing operationParseException - in case of a parse errorprotected ProtocolVersion createProtocolVersion(int major, int minor)
parseProtocolVersion(java.lang.String, org.apache.http.message.LineParser).major - the major version number, for example 1 in HTTP/1.0minor - the minor version number, for example 0 in HTTP/1.0public boolean hasProtocolVersion(CharArrayBuffer buffer, ParserCursor cursor)
LineParserLineParser.parseProtocolVersion(org.apache.http.util.CharArrayBuffer, org.apache.http.message.ParserCursor) would not
detect a parse error.
This can be used to detect garbage lines before a request
or status line.hasProtocolVersion in interface LineParserbuffer - a buffer holding the line to inspectcursor - the cursor at which to check for a protocol version, or
negative for "end of line". Whether the check tolerates
whitespace before or after the protocol version is
implementation dependent.true if there is a protocol version at the
argument index (possibly ignoring whitespace),
false otherwisepublic static RequestLine parseRequestLine(String value, LineParser parser) throws ParseException
ParseExceptionpublic RequestLine parseRequestLine(CharArrayBuffer buffer, ParserCursor cursor) throws ParseException
parseRequestLine in interface LineParserbuffer - a buffer holding the line to parsecursor - the parser cursor containing the current position and
the bounds within the buffer for the parsing operationParseException - in case of a parse errorprotected RequestLine createRequestLine(String method, String uri, ProtocolVersion ver)
parseRequestLine(java.lang.String, org.apache.http.message.LineParser).method - the request methoduri - the requested URIver - the protocol versionpublic static StatusLine parseStatusLine(String value, LineParser parser) throws ParseException
ParseExceptionpublic StatusLine parseStatusLine(CharArrayBuffer buffer, ParserCursor cursor) throws ParseException
LineParserparseStatusLine in interface LineParserbuffer - a buffer holding the line to parsecursor - the parser cursor containing the current position and
the bounds within the buffer for the parsing operationParseException - in case of a parse errorprotected StatusLine createStatusLine(ProtocolVersion ver, int status, String reason)
parseStatusLine(java.lang.String, org.apache.http.message.LineParser).ver - the protocol versionstatus - the status codereason - the reason phrasepublic static Header parseHeader(String value, LineParser parser) throws ParseException
ParseExceptionpublic Header parseHeader(CharArrayBuffer buffer) throws ParseException
LineParserparseHeader in interface LineParserbuffer - a buffer holding the full header line.
This buffer MUST NOT be re-used afterwards, since
the returned object may reference the contents later.ParseException - in case of a parse errorprotected void skipWhitespace(CharArrayBuffer buffer, ParserCursor cursor)
Copyright © 2005–2022 The Apache Software Foundation. All rights reserved.