### Question:
GzipEncoder extends MessageToMessageEncoder<FullHttpRequest> { @Override protected void encode(ChannelHandlerContext ctx, FullHttpRequest msg, List<Object> out) { final long start = registry.clock().wallTime(); ByteBuf buf = ctx.alloc().directBuffer(); try ( ByteBufOutputStream bbos = new ByteBufOutputStream(buf); GZIPOutputStream gos = new GZIPOutputStream(bbos) ) { msg.content().readBytes(gos, msg.content().readableBytes()); gos.finish(); FullHttpRequest message = msg.replace(buf.retain()); out.add(message); } catch (Exception e) { ctx.fireExceptionCaught(new IOException("error encoding message", e)); } finally { buf.release(); } final long end = registry.clock().wallTime(); encodeTime.record(end - start, TimeUnit.MILLISECONDS); } GzipEncoder(Registry registry);   }### Answer:
@Test void shouldCompressFullHttpRequest() throws IOException { FullHttpRequest request = new DefaultFullHttpRequest( HttpVersion.HTTP_1_1, HttpMethod.POST, "http: request.content().writeBytes(new byte[1024]); int uncompressedSize = request.content().readableBytes(); encoder.encode(ctx, request, out); assertFalse(out.isEmpty()); FullHttpRequest result = (FullHttpRequest) out.get(0); int compressedSize = result.content().readableBytes(); assertTrue(uncompressedSize > compressedSize); byte[] b = new byte[result.content().readableBytes()]; result.content().readBytes(b); assertEquals((byte) 0x8b1f, b[0]); }