Class AsyncMiddleManServlet.GZIPContentTransformer
- java.lang.Object
-
- org.eclipse.jetty.proxy.AsyncMiddleManServlet.GZIPContentTransformer
-
- All Implemented Interfaces:
AsyncMiddleManServlet.ContentTransformer
- Enclosing class:
- AsyncMiddleManServlet
public static class AsyncMiddleManServlet.GZIPContentTransformer extends java.lang.Object implements AsyncMiddleManServlet.ContentTransformer
-
-
Field Summary
-
Fields inherited from interface org.eclipse.jetty.proxy.AsyncMiddleManServlet.ContentTransformer
IDENTITY
-
-
Constructor Summary
Constructors Constructor Description GZIPContentTransformer(HttpClient httpClient, AsyncMiddleManServlet.ContentTransformer transformer)
GZIPContentTransformer(AsyncMiddleManServlet.ContentTransformer transformer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
transform(java.nio.ByteBuffer input, boolean finished, java.util.List<java.nio.ByteBuffer> output)
Transforms the given input byte buffers into (possibly multiple) byte buffers.
-
-
-
Constructor Detail
-
GZIPContentTransformer
public GZIPContentTransformer(AsyncMiddleManServlet.ContentTransformer transformer)
-
GZIPContentTransformer
public GZIPContentTransformer(HttpClient httpClient, AsyncMiddleManServlet.ContentTransformer transformer)
-
-
Method Detail
-
transform
public void transform(java.nio.ByteBuffer input, boolean finished, java.util.List<java.nio.ByteBuffer> output) throws java.io.IOException
Description copied from interface:AsyncMiddleManServlet.ContentTransformer
Transforms the given input byte buffers into (possibly multiple) byte buffers.
The transformation must happen synchronously in the context of a call to this method (it is not supported to perform the transformation in another thread spawned during the call to this method). The transformation may happen or not, depending on the transformer implementation. For example, a buffering transformer may buffer the input aside, and only perform the transformation when the whole input is provided (by looking at the
finished
flag).The input buffer will be cleared and reused after the call to this method. Implementations that want to buffer aside the input (or part of it) must copy the input bytes that they want to buffer.
Typical implementations:
// Identity transformation (no transformation, the input is copied to the output) public void transform(ByteBuffer input, boolean finished, List<ByteBuffer> output) { output.add(input); } // Discard transformation (all input is discarded) public void transform(ByteBuffer input, boolean finished, List<ByteBuffer> output) { // Empty } // Buffering identity transformation (all input is buffered aside until it is finished) public void transform(ByteBuffer input, boolean finished, List<ByteBuffer> output) { ByteBuffer copy = ByteBuffer.allocate(input.remaining()); copy.put(input).flip(); store(copy); if (finished) { List<ByteBuffer> copies = retrieve(); output.addAll(copies); } }
- Specified by:
transform
in interfaceAsyncMiddleManServlet.ContentTransformer
- Parameters:
input
- the input content to transform (may be of length zero)finished
- whether the input content is finished or more will comeoutput
- where to put the transformed output content- Throws:
java.io.IOException
- in case of transformation failures
-
-