HttpClientOperations extends HttpOperations<NettyInbound, NettyOutbound> implements HttpClientResponse, HttpClientRequest { @Override public HttpClientOperations addHandler(ChannelHandler handler) { super.addHandler(handler); return this; } HttpClientOperations(HttpClientOperations replaced);   HttpClientOperations(Connection c, ConnectionObserver listener, ClientCookieEncoder encoder, ClientCookieDecoder decoder); @Override HttpClientRequest addCookie(Cookie cookie); @Override HttpClientOperations addHandlerLast(ChannelHandler handler); @Override HttpClientOperations addHandlerLast(String name, ChannelHandler handler); @Override HttpClientOperations addHandlerFirst(ChannelHandler handler); @Override HttpClientOperations addHandlerFirst(String name, ChannelHandler handler); @Override HttpClientOperations addHandler(ChannelHandler handler); @Override @SuppressWarnings("FutureReturnValueIgnored") HttpClientOperations addHandler(String name, ChannelHandler handler); @Override HttpClientOperations replaceHandler(String name, ChannelHandler handler); @Override HttpClientOperations removeHandler(String name); @Override HttpClientRequest addHeader(CharSequence name, CharSequence value); @Override InetSocketAddress address(); void chunkedTransfer(boolean chunked); @Override HttpClientOperations withConnection(Consumer<? super Connection> withConnection); @Override Map<CharSequence, Set<Cookie>> cookies(); @Override HttpClientRequest header(CharSequence name, CharSequence value); @Override HttpClientRequest headers(HttpHeaders headers); @Override boolean isFollowRedirect(); @Override HttpClientRequest responseTimeout(Duration timeout); @Override boolean isKeepAlive(); @Override boolean isWebsocket(); @Override HttpMethod method(); @Override final HttpClientOperations onDispose(Disposable onDispose); @Override ContextView currentContextView(); @Override String[] redirectedFrom(); @Override HttpHeaders requestHeaders(); @Override HttpHeaders responseHeaders(); @Override NettyOutbound send(Publisher<? extends ByteBuf> source); @Override HttpResponseStatus status(); @Override final String uri(); @Override final String fullPath(); @Override String resourceUrl(); @Override final HttpVersion version();  }
@Test public void addDecoderReplaysLastHttp() { ByteBuf buf = Unpooled.copiedBuffer("{\"foo\":1}", CharsetUtil.UTF_8); EmbeddedChannel channel = new EmbeddedChannel(); new HttpClientOperations(() -> channel, ConnectionObserver.emptyListener(), ClientCookieEncoder.STRICT, ClientCookieDecoder.STRICT) .addHandler(new JsonObjectDecoder()); channel.writeInbound(new DefaultLastHttpContent(buf)); MatcherAssert.assertThat(channel.pipeline().names().iterator().next(), is("JsonObjectDecoder$extractor")); Object content = channel.readInbound(); MatcherAssert.assertThat(content, instanceOf(ByteBuf.class)); ((ByteBuf) content).release(); content = channel.readInbound(); MatcherAssert.assertThat(content, instanceOf(LastHttpContent.class)); ((LastHttpContent) content).release(); MatcherAssert.assertThat(channel.readInbound(), nullValue()); }
@Test public void addNamedDecoderReplaysLastHttp() { ByteBuf buf = Unpooled.copiedBuffer("{\"foo\":1}", CharsetUtil.UTF_8); EmbeddedChannel channel = new EmbeddedChannel(); new HttpClientOperations(() -> channel, ConnectionObserver.emptyListener(), ClientCookieEncoder.STRICT, ClientCookieDecoder.STRICT) .addHandler("json", new JsonObjectDecoder()); channel.writeInbound(new DefaultLastHttpContent(buf)); MatcherAssert.assertThat(channel.pipeline().names().iterator().next(), is("json$extractor")); Object content = channel.readInbound(); MatcherAssert.assertThat(content, instanceOf(ByteBuf.class)); ((ByteBuf) content).release(); content = channel.readInbound(); MatcherAssert.assertThat(content, instanceOf(LastHttpContent.class)); ((LastHttpContent) content).release(); MatcherAssert.assertThat(channel.readInbound(), nullValue()); }
@Test public void addEncoderReplaysLastHttp() { ByteBuf buf = Unpooled.copiedBuffer("{\"foo\":1}", CharsetUtil.UTF_8); EmbeddedChannel channel = new EmbeddedChannel(); new HttpClientOperations(() -> channel, ConnectionObserver.emptyListener(), ClientCookieEncoder.STRICT, ClientCookieDecoder.STRICT) .addHandler(new JsonObjectDecoder()); channel.writeInbound(new DefaultLastHttpContent(buf)); MatcherAssert.assertThat(channel.pipeline().names().iterator().next(), is("JsonObjectDecoder$extractor")); Object content = channel.readInbound(); MatcherAssert.assertThat(content, instanceOf(ByteBuf.class)); ((ByteBuf) content).release(); content = channel.readInbound(); MatcherAssert.assertThat(content, instanceOf(LastHttpContent.class)); ((LastHttpContent) content).release(); MatcherAssert.assertThat(channel.readInbound(), nullValue()); }
@Test public void addNamedEncoderReplaysLastHttp() { ByteBuf buf = Unpooled.copiedBuffer("{\"foo\":1}", CharsetUtil.UTF_8); EmbeddedChannel channel = new EmbeddedChannel(); new HttpClientOperations(() -> channel, ConnectionObserver.emptyListener(), ClientCookieEncoder.STRICT, ClientCookieDecoder.STRICT) .addHandler("json", new JsonObjectDecoder()); channel.writeInbound(new DefaultLastHttpContent(buf)); MatcherAssert.assertThat(channel.pipeline().names().iterator().next(), is("json$extractor")); Object content = channel.readInbound(); MatcherAssert.assertThat(content, instanceOf(ByteBuf.class)); ((ByteBuf) content).release(); content = channel.readInbound(); MatcherAssert.assertThat(content, instanceOf(LastHttpContent.class)); ((LastHttpContent) content).release(); MatcherAssert.assertThat(channel.readInbound(), nullValue()); }