Merged branch 'jetty-9.4.x' into 'master'.

This commit is contained in:
Simone Bordet 2017-10-03 18:02:31 +02:00
commit 30592719c0
1 changed files with 12 additions and 2 deletions

View File

@ -53,6 +53,8 @@ import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.CountingCallback;
import org.eclipse.jetty.util.IteratingCallback;
import org.eclipse.jetty.util.component.Destroyable;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
/**
* <p>Servlet 3.1 asynchronous proxy servlet with capability
@ -757,6 +759,8 @@ public class AsyncMiddleManServlet extends AbstractProxyServlet
public static class GZIPContentTransformer implements ContentTransformer
{
private static final Logger logger = Log.getLogger(GZIPContentTransformer.class);
private final List<ByteBuffer> buffers = new ArrayList<>(2);
private final ContentDecoder decoder = new GZIPContentDecoder();
private final ContentTransformer transformer;
@ -780,6 +784,9 @@ public class AsyncMiddleManServlet extends AbstractProxyServlet
@Override
public void transform(ByteBuffer input, boolean finished, List<ByteBuffer> output) throws IOException
{
if (logger.isDebugEnabled())
logger.debug("Ungzipping {} bytes, finished={}", input.remaining(), finished);
if (!input.hasRemaining())
{
if (finished)
@ -790,8 +797,11 @@ public class AsyncMiddleManServlet extends AbstractProxyServlet
while (input.hasRemaining())
{
ByteBuffer decoded = decoder.decode(input);
if (decoded.hasRemaining())
transformer.transform(decoded, finished && !input.hasRemaining(), buffers);
boolean complete = finished && !input.hasRemaining();
if (logger.isDebugEnabled())
logger.debug("Ungzipped {} bytes, complete={}", decoded.remaining(), complete);
if (decoded.hasRemaining() || complete)
transformer.transform(decoded, complete, buffers);
}
}