@Override public HttpClientOperations addHandler(ChannelHandler handler) { super.addHandler(handler); return this; }
@Override public HttpClientOperations addHandlerFirst(ChannelHandler handler) { super.addHandlerFirst(handler); return this; }
@Override public HttpClientOperations addHandlerLast(ChannelHandler handler) { super.addHandlerLast(handler); return this; }
@Override public String toString() { if (isWebsocket()) { return "ws{uri=" + uri()+", connection="+connection()+"}"; } return method().name() + "{uri=" + uri()+", connection="+connection()+"}"; }
@Override public Mono<Void> then() { if (hasSentHeaders()) { return Mono.empty(); } return FutureMono.deferFuture(() -> { if (markSentHeaders()) { HttpMessage msg; if (HttpUtil.isContentLengthSet(outboundHttpMessage())) { outboundHttpMessage().headers() .remove(HttpHeaderNames.TRANSFER_ENCODING); if (HttpUtil.getContentLength(outboundHttpMessage(), 0) == 0) { markSentBody(); msg = newFullEmptyBodyMessage(); } else { msg = outboundHttpMessage(); } } else { msg = outboundHttpMessage(); } preSendHeadersAndStatus(); return channel().writeAndFlush(msg); } else { return channel().newSucceededFuture(); } }); }
@Override public HttpOperations<INBOUND, OUTBOUND> addHandler(String name, ChannelHandler handler) { super.addHandler(name, handler); if(channel().pipeline().context(handler) == null){ return this; } autoAddHttpExtractor(this, name, handler); return this; }
@Override public Mono<Void> then() { ByteBufAllocator alloc = parent.channel().alloc(); return Flux.from(source) .collect(alloc::heapBuffer, ByteBuf::writeBytes) .flatMap(agg -> { if (!HttpUtil.isTransferEncodingChunked(request) && !HttpUtil.isContentLengthSet(request)) { request.headers() .setInt(HttpHeaderNames.CONTENT_LENGTH, agg.readableBytes()); } if (agg.readableBytes() > 0) { return parent.then().thenEmpty(FutureMono.disposableWriteAndFlush(parent.channel(), Mono.just(agg))); } agg.release(); return parent.then(); }); }
@Override public final NettyOutbound sendFile(Path file, long position, long count) { Objects.requireNonNull(file); if (hasSentHeaders()) { return super.sendFile(file, position, count); } if (!HttpUtil.isTransferEncodingChunked(outboundHttpMessage()) && !HttpUtil.isContentLengthSet( outboundHttpMessage()) && count < Integer.MAX_VALUE) { outboundHttpMessage().headers() .setInt(HttpHeaderNames.CONTENT_LENGTH, (int) count); } else if (!HttpUtil.isContentLengthSet(outboundHttpMessage())) { outboundHttpMessage().headers() .remove(HttpHeaderNames.CONTENT_LENGTH) .remove(HttpHeaderNames.TRANSFER_ENCODING); HttpUtil.setTransferEncodingChunked(outboundHttpMessage(), true); } return super.sendFile(file, position, count); }
testContext.addHandlerLast("foo", handler); HttpOperations.autoAddHttpExtractor(testContext, "foo", handler);
@Override public ByteBufAllocator alloc() { return parent.alloc(); }
@Override public Mono<Void> then() { if (hasSentHeaders()) { return Mono.empty(); } return FutureMono.deferFuture(() -> { if (markSentHeaders()) { HttpMessage msg; if (HttpUtil.isContentLengthSet(outboundHttpMessage())) { outboundHttpMessage().headers() .remove(HttpHeaderNames.TRANSFER_ENCODING); if (HttpUtil.getContentLength(outboundHttpMessage(), 0) == 0) { markSentBody(); msg = newFullEmptyBodyMessage(); } else { msg = outboundHttpMessage(); } } else { msg = outboundHttpMessage(); } preSendHeadersAndStatus(); return channel().writeAndFlush(msg); } else { return channel().newSucceededFuture(); } }); }
@Override public String toString() { if (isWebsocket()) { return "ws{uri=" + uri()+", connection="+connection()+"}"; } return method().name() + "{uri=" + uri()+", connection="+connection()+"}"; }
@Override public HttpOperations<INBOUND, OUTBOUND> addHandler(String name, ChannelHandler handler) { super.addHandler(name, handler); if(channel().pipeline().context(handler) == null){ return this; } autoAddHttpExtractor(this, name, handler); return this; }
@Override public Mono<Void> then() { ByteBufAllocator alloc = parent.channel().alloc(); return Flux.from(source) .collect(alloc::heapBuffer, ByteBuf::writeBytes) .flatMap(agg -> { if (!HttpUtil.isTransferEncodingChunked(request) && !HttpUtil.isContentLengthSet(request)) { request.headers() .setInt(HttpHeaderNames.CONTENT_LENGTH, agg.readableBytes()); } return parent.then().thenEmpty(FutureMono.disposableWriteAndFlush(parent.channel(), Mono.just(agg))); }); }
@Override public final NettyOutbound sendFile(Path file, long position, long count) { Objects.requireNonNull(file); if (hasSentHeaders()) { return super.sendFile(file, position, count); } if (!HttpUtil.isTransferEncodingChunked(outboundHttpMessage()) && !HttpUtil.isContentLengthSet( outboundHttpMessage()) && count < Integer.MAX_VALUE) { outboundHttpMessage().headers() .setInt(HttpHeaderNames.CONTENT_LENGTH, (int) count); } else if (!HttpUtil.isContentLengthSet(outboundHttpMessage())) { outboundHttpMessage().headers() .remove(HttpHeaderNames.CONTENT_LENGTH) .remove(HttpHeaderNames.TRANSFER_ENCODING); HttpUtil.setTransferEncodingChunked(outboundHttpMessage(), true); } return super.sendFile(file, position, count); }
@Override public ByteBufAllocator alloc() { return parent.alloc(); }
@Override public HttpClientOperations addHandlerLast(String name, ChannelHandler handler) { super.addHandlerLast(name, handler); return this; }
@Override public HttpClientOperations addHandlerFirst(String name, ChannelHandler handler) { super.addHandlerFirst(name, handler); return this; }
@Override @SuppressWarnings("FutureReturnValueIgnored") public HttpClientOperations addHandler(String name, ChannelHandler handler) { // Returned value is deliberately ignored super.addHandler(name, handler); return this; }
@Override public HttpClientOperations addHandlerLast(ChannelHandler handler) { super.addHandlerLast(handler); return this; }