sardine.server.HttpChunkContentCompressor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sardine Show documentation
Show all versions of sardine Show documentation
lightweight framework for creating small standalone java applications in a micro service way.
The newest version!
package sardine.server;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPromise;
import io.netty.handler.codec.http.DefaultHttpContent;
import io.netty.handler.codec.http.HttpContentCompressor;
/**
* @author bruce-sha
* 2015/6/15
*/
public final class HttpChunkContentCompressor extends HttpContentCompressor {
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
/*
convert ByteBuf to HttpContent to make it work with compression.
This is needed as we use the ChunkedWriteHandler to send files when compression is enabled.
*/
if (msg instanceof ByteBuf) msg = new DefaultHttpContent((ByteBuf) msg);
super.write(ctx, msg, promise);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy