Interface HttpOutput.Interceptor
- All Superinterfaces:
Content.Sink
- All Known Subinterfaces:
BufferedResponseHandler.BufferedInterceptor
- All Known Implementing Classes:
HttpChannel
- Enclosing class:
HttpOutput
The Interceptor can be used to implement translations (eg Gzip) or additional buffering that acts on all output. Interceptors are created in a chain, so that multiple concerns may intercept.
The HttpChannel
is an HttpOutput.Interceptor
and is always the
last link in any Interceptor chain.
Responses are committed by the first call to
write(ByteBuffer, boolean, Callback)
and closed by a call to write(ByteBuffer, boolean, Callback)
with the last boolean set true. If no content is available to commit
or close, then a null buffer is passed.
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
Reset the buffers.default void
write
(boolean last, ByteBuffer content, Callback callback) Writes the givenByteBuffer
, notifying theCallback
when the write is complete.void
write
(ByteBuffer content, boolean last, Callback callback) Write content.
-
Method Details
-
write
Write content. The response is committed by the first call to write and is closed by a call with last == true. Empty content buffers may be passed to force a commit or close.- Parameters:
content
- The content to be written or an empty buffer.last
- True if this is the last call to writecallback
- The callback to use to indicateCallback.succeeded()
orCallback.failed(Throwable)
.
-
write
Description copied from interface:Content.Sink
Writes the given
ByteBuffer
, notifying theCallback
when the write is complete.Implementations guarantee that calls to this method are safely reentrant so that stack overflows are avoided in the case of mutual recursion between the execution of the
Callback
and a call to this method.- Specified by:
write
in interfaceContent.Sink
- Parameters:
last
- whether the ByteBuffer is the last to writecontent
- the ByteBuffer to writecallback
- the callback to notify when the write operation is complete
-
getNextInterceptor
HttpOutput.Interceptor getNextInterceptor()- Returns:
- The next Interceptor in the chain or null if this is the last Interceptor in the chain.
-
resetBuffer
Reset the buffers.If the Interceptor contains buffers then reset them.
- Throws:
IllegalStateException
- Thrown if the response has been committed and buffers and/or headers cannot be reset.
-