Package org.apache.hc.core5.http.impl.io
Class AbstractMessageWriter<T extends HttpMessage>
- java.lang.Object
-
- org.apache.hc.core5.http.impl.io.AbstractMessageWriter<T>
-
- All Implemented Interfaces:
HttpMessageWriter<T>
- Direct Known Subclasses:
DefaultHttpRequestWriter
,DefaultHttpResponseWriter
public abstract class AbstractMessageWriter<T extends HttpMessage> extends java.lang.Object implements HttpMessageWriter<T>
Abstract base class for HTTP message writers that serialize output to an instance ofSessionOutputBuffer
.- Since:
- 4.0
-
-
Field Summary
Fields Modifier and Type Field Description private CharArrayBuffer
lineBuf
private LineFormatter
lineFormatter
-
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) LineFormatter
getLineFormatter()
void
write(T message, SessionOutputBuffer buffer, java.io.OutputStream outputStream)
Serializes an instance ofMessageHeaders
to the given output stream.protected abstract void
writeHeadLine(T message, CharArrayBuffer lineBuf)
Subclasses must override this method to write out the first header line based on theHttpMessage
passed as a parameter.
-
-
-
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 Ifnull
BasicLineFormatter.INSTANCE
will be used.- Since:
- 4.3
-
-
Method Detail
-
getLineFormatter
LineFormatter getLineFormatter()
-
writeHeadLine
protected abstract void writeHeadLine(T message, CharArrayBuffer lineBuf) throws java.io.IOException
Subclasses must override this method to write out the first header line based on theHttpMessage
passed as a parameter.- Parameters:
message
- the message whose first line is to be written out.lineBuf
- line buffer- Throws:
java.io.IOException
- in case of an I/O error.
-
write
public void write(T message, SessionOutputBuffer buffer, java.io.OutputStream outputStream) throws java.io.IOException, HttpException
Description copied from interface:HttpMessageWriter
Serializes an instance ofMessageHeaders
to the given output stream.- Specified by:
write
in interfaceHttpMessageWriter<T extends HttpMessage>
- Parameters:
message
- HTTP message headbuffer
- session output buffer- Throws:
java.io.IOException
- in case of an I/O errorHttpException
- in case of HTTP protocol violation
-
-