@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 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 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 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 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(); } }); }