@Override public Mono<Void> writeWith(Publisher<? extends DataBuffer> body) { return doCommit(() -> { Flux<ByteBuf> byteBufFlux = Flux.from(body).map(NettyDataBufferFactory::toByteBuf); return this.outbound.send(byteBufFlux).then(); }); }
.subscribe(c -> latch.countDown()); return out.send(Flux.range(1, elem) .map(i -> new Pojo("test" + i)) .log("send")
return out.send(Flux.just(new Pojo("John" + " Doe")) .map(s -> { try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
@Override public ListenableFuture<Void> send(Message<P> message) { ByteBuf byteBuf = this.outbound.alloc().buffer(); this.codec.encode(message, byteBuf); Mono<Void> sendCompletion = this.outbound.send(Mono.just(byteBuf)).then(); return new MonoToListenableFutureAdapter<>(sendCompletion); }
@Override public Mono<Void> writeWith(Publisher<? extends DataBuffer> body) { return doCommit(() -> { Flux<ByteBuf> byteBufFlux = Flux.from(body).map(NettyDataBufferFactory::toByteBuf); return this.outbound.send(byteBufFlux).then(); }); }
.send(request.getBody().map(dataBuffer -> ((NettyDataBuffer) dataBuffer).getNativeBuffer())); }).responseConnection((res, connection) -> {
@Override public ListenableFuture<Void> send(Message<P> message) { ByteBuf byteBuf = this.outbound.alloc().buffer(); this.codec.encode(message, byteBuf); Mono<Void> sendCompletion = this.outbound.send(Mono.just(byteBuf)).then(); return new MonoToListenableFutureAdapter<>(sendCompletion); }
/** * Send bytes 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 sendByteArray(Publisher<? extends byte[]> dataStream) { return send(ReactorNetty.publisherOrScalarMap(dataStream, Unpooled::wrappedBuffer)); }
/** * Send bytes 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 sendByteArray(Publisher<? extends byte[]> dataStream) { return send(ReactorNetty.publisherOrScalarMap(dataStream, Unpooled::wrappedBuffer)); }
@Override public Mono<Void> writeWith(Publisher<? extends DataBuffer> body) { return doCommit(() -> this.httpRequest .send(Flux.from(body).map(NettyDataBufferFactory::toByteBuf)).then()); }
@Override public Mono<Void> writeWith(Publisher<? extends DataBuffer> body) { return doCommit(() -> { Flux<ByteBuf> byteBufFlux = Flux.from(body).map(NettyDataBufferFactory::toByteBuf); return this.outbound.send(byteBufFlux).then(); }); }
@Override public ListenableFuture<Void> send(Message<P> message) { ByteBuf byteBuf = this.outbound.alloc().buffer(); this.codec.encode(message, byteBuf); Mono<Void> sendCompletion = this.outbound.send(Mono.just(byteBuf)).then(); return new MonoToListenableFutureAdapter<>(sendCompletion); }
@Override public ListenableFuture<Void> send(Message<P> message) { ByteBuf byteBuf = this.outbound.alloc().buffer(); this.codec.encode(message, byteBuf); Mono<Void> sendCompletion = this.outbound.send(Mono.just(byteBuf)).then(); return new MonoToListenableFutureAdapter<>(sendCompletion); }
private Mono<? extends Void> send0(Connection conn, Message message, Address address) { // check sender not null Objects.requireNonNull(message.sender(), "sender must be not null"); // do send return conn.outbound() .options(SendOptions::flushOnEach) .send( Mono.just(message) .flatMap(msg -> networkEmulator.tryFail(msg, address)) .flatMap(msg -> networkEmulator.tryDelay(msg, address)) .map(this::toByteBuf)) .then(); }
.handle((in, out) -> out.send(in.receive() .asString() .map(jsonDecoder)
@Test public void testIssue444() { doTestIssue444((in, out) -> out.sendObject(Flux.error(new Throwable()) .onErrorResume(ex -> out.sendClose(1001, "Going Away")) .cast(WebSocketFrame.class))); doTestIssue444((in, out) -> out.options(o -> o.flushOnEach(false)) .send(Flux.range(0, 10) .map(i -> { if (i == 5) { out.sendClose(1001, "Going Away").subscribe(); } return Unpooled.copiedBuffer((i + "").getBytes(Charset.defaultCharset())); }))); doTestIssue444((in, out) -> out.sendObject(Flux.error(new Throwable()) .onErrorResume(ex -> Flux.empty()) .cast(WebSocketFrame.class)) .then(Mono.defer(() -> out.sendObject( new CloseWebSocketFrame(1001, "Going Away")).then()))); }
@Test public void testExplicitEmptyBodyOnGetWorks() throws Exception { SelfSignedCertificate ssc = new SelfSignedCertificate(); SslContext sslServer = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey()) .build(); SslContext sslClient = SslContextBuilder.forClient() .trustManager(InsecureTrustManagerFactory.INSTANCE) .build(); DisposableServer server = HttpServer.create() .secure(ssl -> ssl.sslContext(sslServer)) .port(0) .handle((req, res) -> res.send(req.receive().retain())) .bindNow(); ConnectionProvider pool = ConnectionProvider.fixed("test", 1); for (int i = 0; i < 4; i++) { StepVerifier.create(createHttpClientForContextWithAddress(server, pool) .secure(ssl -> ssl.sslContext(sslClient)) .request(HttpMethod.GET) .uri("/") .send((req, out) -> out.send(Flux.empty())) .responseContent()) .expectComplete() .verify(Duration.ofSeconds(30)); } pool.dispose(); server.disposeNow(); }