Top Description Inners Fields Constructors Methods
org.apache.hc.core5.http.impl.nio

public abstract Class AbstractMessageParser<T extends org.apache.hc.core5.http.HttpMessage>

extends Object
implements NHttpMessageParser<T extends HttpMessage>
Class Inheritance
All Implemented Interfaces
org.apache.hc.core5.http.nio.NHttpMessageParser
Known Direct Subclasses
org.apache.hc.core5.http.impl.nio.DefaultHttpRequestParser, org.apache.hc.core5.http.impl.nio.DefaultHttpResponseParser
Imports
java.io.IOException, java.util.ArrayList, .List, org.apache.hc.core5.http.HttpException, .HttpMessage, .MessageConstraintException, org.apache.hc.core5.http.config.Http1Config, org.apache.hc.core5.http.message.LazyLineParser, .LineParser, org.apache.hc.core5.http.nio.SessionInputBuffer, .NHttpMessageParser, org.apache.hc.core5.util.Args, .CharArrayBuffer

Abstract NHttpMessageParser that serves as a base for all message parser implementations.
Since
4.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static enum

Field Summary

Modifier and TypeField and Description
private int
private final List<CharArrayBuffer>
private CharArrayBuffer
private final LineParser
private T
private final Http1Config
private AbstractMessageParser.State

Constructor Summary

AccessConstructor and Description
public
AbstractMessageParser(final LineParser
the line parser. If null org.apache.hc.core5.http.message.LazyLineParser#INSTANCE will be used.
lineParser
,
final Http1Config
Message constraints. If null Http1Config#DEFAULT will be used.
messageConstraints
)

Creates an instance of AbstractMessageParser.

Method Summary

Modifier and TypeMethod and Description
protected abstract T

Returns:

HTTP message.
createMessage
(CharArrayBuffer
the line buffer.
buffer
)

Creates HttpMessage instance based on the content of the input buffer containing the first line of the incoming HTTP message.

pack-priv LineParser
public T
parse(final SessionInputBuffer
session input buffer.
sessionBuffer
,
final boolean
end of stream flag
endOfStream
)

Implements org.apache.hc.core5.http.nio.NHttpMessageParser.parse.

Attempts to parse a complete message head from the content of the internal buffer.
private void
private T
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

emptyLineCountback to summary
private int emptyLineCount
headerBufsback to summary
private final List<CharArrayBuffer> headerBufs
lineBufback to summary
private CharArrayBuffer lineBuf
lineParserback to summary
private final LineParser lineParser
messageback to summary
private T message
messageConstraintsback to summary
private final Http1Config messageConstraints
stateback to summary
private AbstractMessageParser.State state

Constructor Detail

AbstractMessageParserback to summary
public AbstractMessageParser(final LineParser lineParser, final Http1Config messageConstraints)

Creates an instance of AbstractMessageParser.

Parameters
lineParser:LineParser

the line parser. If null org.apache.hc.core5.http.message.LazyLineParser#INSTANCE will be used.

messageConstraints:Http1Config

Message constraints. If null Http1Config#DEFAULT will be used.

Since
4.3

Method Detail

createMessageback to summary
protected abstract T createMessage(CharArrayBuffer buffer) throws HttpException

Creates HttpMessage instance based on the content of the input buffer containing the first line of the incoming HTTP message.

Parameters
buffer:CharArrayBuffer

the line buffer.

Returns:T

HTTP message.

Exceptions
HttpException:
in case of HTTP protocol violation
getLineParserback to summary
pack-priv LineParser getLineParser()
parseback to summary
public T parse(final SessionInputBuffer sessionBuffer, final boolean endOfStream) throws IOException, HttpException

Implements org.apache.hc.core5.http.nio.NHttpMessageParser.parse.

Doc from org.apache.hc.core5.http.nio.NHttpMessageParser.parse.

Attempts to parse a complete message head from the content of the internal buffer. If the message in the input buffer is incomplete this method will return null.

Parameters
sessionBuffer:SessionInputBuffer

session input buffer.

endOfStream:boolean

end of stream flag

Returns:T

HTTP message head, if available, null otherwise.

Annotations
@Override
Exceptions
IOException:
in case of an I/O error.
HttpException:
in case the HTTP message is malformed or violates the HTTP protocol.
parseHeaderback to summary
private void parseHeader() throws IOException
parseHeadLineback to summary
private T parseHeadLine() throws IOException, HttpException
resetback to summary
public void reset()

Implements org.apache.hc.core5.http.nio.NHttpMessageParser.reset.

Doc from org.apache.hc.core5.http.nio.NHttpMessageParser.reset.

Resets the parser. The parser will be ready to start parsing another HTTP message.

Annotations
@Override
org.apache.hc.core5.http.impl.nio back to summary

private final Enum AbstractMessageParser.State

extends Enum<AbstractMessageParser.State>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final AbstractMessageParser.State
public static final AbstractMessageParser.State
public static final AbstractMessageParser.State

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static AbstractMessageParser.State
public static AbstractMessageParser.State[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

COMPLETEDback to summary
public static final AbstractMessageParser.State COMPLETED
READ_HEAD_LINEback to summary
public static final AbstractMessageParser.State READ_HEAD_LINE
READ_HEADERSback to summary
public static final AbstractMessageParser.State READ_HEADERS

Constructor Detail

Stateback to summary
private State()

Method Detail

valueOfback to summary
public static AbstractMessageParser.State valueOf(String name)
valuesback to summary
public static AbstractMessageParser.State[] values()