@Override
    public void prepareUpgradeFrom(ChannelHandlerContext ctx) {
        ((Encoder) outboundHandler()).upgraded = true;
    }
@Test
    public void testWriteThroughAfterUpgrade() {
        HttpClientCodec codec = new HttpClientCodec();
        EmbeddedChannel ch = new EmbeddedChannel(codec);
        codec.prepareUpgradeFrom(null);

        ByteBuf buffer = ch.alloc().buffer();
        assertThat(buffer.refCnt(), is(1));
        assertTrue(ch.writeOutbound(buffer));
        // buffer should pass through unchanged
        assertThat(ch.<ByteBuf>readOutbound(), sameInstance(buffer));
        assertThat(buffer.refCnt(), is(1));

        buffer.release();
    }