/** * Subscribe a {@code Void} subscriber to this outbound and trigger all eventual * parent outbound send. * * @param s the {@link Subscriber} to listen for send sequence completion/failure */ @Override default void subscribe(Subscriber<? super Void> s) { then().subscribe(s); }
/** * Send headers and empty content thus delimiting a full empty body http request * * @return a {@link Mono} successful on committed response * * @see #send(Publisher) */ default Mono<Void> send() { return sendObject(Unpooled.EMPTY_BUFFER).then(); }
/** * Send headers and empty content thus delimiting a full empty body http response. * * @return a {@link Mono} successful on committed response * @see #send(Publisher) */ default Mono<Void> send(){ return sendObject(Unpooled.EMPTY_BUFFER).then(); }
OutboundThen(NettyOutbound source, Publisher<Void> thenPublisher) { this.sourceContext = source.context(); Mono<Void> parentMono = source.then(); if (parentMono == Mono.<Void>empty()) { this.thenMono = Mono.from(thenPublisher); } else { this.thenMono = parentMono.thenEmpty(thenPublisher); } }
/** * Send content from given {@link Path} using * {@link java.nio.channels.FileChannel#transferTo(long, long, WritableByteChannel)} * support. If the system supports it and the path resolves to a local file * system {@link File} then transfer will use zero-byte copy * to the peer. * <p>It will * listen for any error on * write and close * on terminal signal (complete|error). If more than one publisher is attached * (multiple calls to send()) completion occurs after all publishers complete. * <p> * Note: this will emit {@link io.netty.channel.FileRegion} in the outbound * {@link io.netty.channel.ChannelPipeline} * Note: Nesting any send* method is not supported. * * @param file the file Path * * @return A Publisher to signal successful sequence write (e.g. after "flush") or any * error during write */ default NettyOutbound sendFile(Path file) { try { return sendFile(file, 0L, Files.size(file)); } catch (IOException e) { return then(Mono.error(e)); } }
/** * Send Object to the peer, listen for any error on write and close on terminal signal * (complete|error). If more than one publisher is attached (multiple calls to send()) * completion occurs after all publishers complete. * Note: Nesting any send* method is not supported. * * @param dataStream the dataStream publishing Buffer items to write on this channel * * @return A Publisher to signal successful sequence write (e.g. after "flush") or any * error during write */ default NettyOutbound sendObject(Publisher<?> dataStream) { return then(FutureMono.disposableWriteAndFlush(context().channel(), dataStream)); }
/** * Send data to the peer, listen for any error on write and close on terminal signal * (complete|error).Each individual {@link Publisher} completion will flush * the underlying IO runtime. * Note: Nesting any send* method is not supported. * * @param dataStreams the dataStream publishing OUT items to write on this channel * * @return A {@link Mono} to signal successful sequence write (e.g. after "flush") or * any error during write */ default NettyOutbound sendGroups(Publisher<? extends Publisher<? extends ByteBuf>> dataStreams) { return then(Flux.from(dataStreams) .concatMapDelayError(this::send, false, 32) .then()); }
@Override public Mono<Void> send(Publisher<WebSocketMessage> messages) { Flux<WebSocketFrame> frames = Flux.from(messages).map(this::toFrame); return getDelegate().getOutbound() .options(NettyPipeline.SendOptions::flushOnEach) .sendObject(frames) .then(); }
/** * Send data to the peer, listen for any error on write and close on terminal signal * (complete|error). * Note: Nesting any send* method is not supported. * * @param msg the object to publish * * @return A {@link Mono} to signal successful sequence write (e.g. after "flush") or * any error during write */ default NettyOutbound sendObject(Object msg) { context().onClose(() -> ReactorNetty.safeRelease(msg)); return then(FutureMono.deferFuture(() -> context().channel() .writeAndFlush(msg))); }
final FileChunkedStrategy<?> strategy = getFileChunkedStrategy(); return then(Mono.using(() -> FileChannel.open(file, StandardOpenOption.READ), fc -> { strategy.preparePipeline(context());
Objects.requireNonNull(file); return then(Mono.using(() -> FileChannel.open(file, StandardOpenOption.READ), fc -> { if ((context().channel().pipeline().get(SslHandler.class) != null) ||