Class AbstractMessageWriter<T extends HttpMessage>
- java.lang.Object
-
- org.apache.hc.core5.http.impl.nio.AbstractMessageWriter<T>
-
- All Implemented Interfaces:
NHttpMessageWriter<T>
- Direct Known Subclasses:
DefaultHttpRequestWriter,DefaultHttpResponseWriter
public abstract class AbstractMessageWriter<T extends HttpMessage> extends java.lang.Object implements NHttpMessageWriter<T>
AbstractNHttpMessageWriterthat serves as a base for all message writer implementations.- Since:
- 4.0
-
-
Field Summary
Fields Modifier and Type Field Description private CharArrayBufferlineBufprivate LineFormatterlineFormatter
-
Constructor Summary
Constructors Constructor Description AbstractMessageWriter(LineFormatter formatter)Creates an instance of AbstractMessageWriter.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) LineFormattergetLineFormatter()voidreset()Resets the writer.voidwrite(T message, SessionOutputBuffer sessionBuffer)Writes out the HTTP message head.protected abstract voidwriteHeadLine(T message, CharArrayBuffer buffer)Writes out the first line ofHttpMessage.
-
-
-
Field Detail
-
lineBuf
private final CharArrayBuffer lineBuf
-
lineFormatter
private final LineFormatter lineFormatter
-
-
Constructor Detail
-
AbstractMessageWriter
public AbstractMessageWriter(LineFormatter formatter)
Creates an instance of AbstractMessageWriter.- Parameters:
formatter- the line formatter IfnullBasicLineFormatter.INSTANCEwill be used.- Since:
- 4.3
-
-
Method Detail
-
getLineFormatter
LineFormatter getLineFormatter()
-
reset
public void reset()
Description copied from interface:NHttpMessageWriterResets the writer. The writer will be ready to start serializing another HTTP message.- Specified by:
resetin interfaceNHttpMessageWriter<T extends HttpMessage>
-
writeHeadLine
protected abstract void writeHeadLine(T message, CharArrayBuffer buffer) throws java.io.IOException
Writes out the first line ofHttpMessage.- Parameters:
message- HTTP message.- Throws:
java.io.IOException
-
write
public void write(T message, SessionOutputBuffer sessionBuffer) throws java.io.IOException, HttpException
Description copied from interface:NHttpMessageWriterWrites out the HTTP message head.- Specified by:
writein interfaceNHttpMessageWriter<T extends HttpMessage>- Parameters:
message- HTTP message.sessionBuffer- session output buffer.- Throws:
java.io.IOException- in case of an I/O error.HttpException- in case the HTTP message is malformed or violates the HTTP protocol.
-
-