/** * Decorate as {@link ByteBufFlux} * * @param source publisher to decorate * * @return a {@link ByteBufFlux} */ public static ByteBufFlux fromInbound(Publisher<?> source) { return fromInbound(source, ByteBufAllocator.DEFAULT); }
/** * Decorate as {@link ByteBufFlux} * * @param source publisher to decorate * * @return a {@link ByteBufFlux} */ public static ByteBufFlux fromInbound(Publisher<?> source) { return fromInbound(source, ByteBufAllocator.DEFAULT); }
@Override public ByteBufFlux receive() { return ByteBufFlux.fromInbound(Mono.error( new IllegalStateException("Receiver Unavailable. The Connection"))); }
@Override public ByteBufFlux receive() { return ByteBufFlux.fromInbound(Mono.error( new IllegalStateException("Receiver Unavailable. The Connection"))); }
@Override public ByteBufFlux receive() { return ByteBufFlux.fromInbound(receiveObject(), connection.channel() .alloc()); }
@Override public ByteBufFlux receive() { return ByteBufFlux.fromInbound(receiveObject(), connection.channel() .alloc()); }
static ByteBufFlux content(TcpClient cachedConfiguration, Function<ChannelOperations<?, ?>, Publisher<ByteBuf>> contentReceiver) { Bootstrap b; try { b = cachedConfiguration.configure(); } catch (Throwable t) { Exceptions.throwIfFatal(t); return ByteBufFlux.fromInbound(Mono.error(t)); } @SuppressWarnings("unchecked") ByteBufAllocator alloc = (ByteBufAllocator) b.config() .options() .getOrDefault(ChannelOption.ALLOCATOR, ByteBufAllocator.DEFAULT); @SuppressWarnings("unchecked") Mono<ChannelOperations<?, ?>> connector = (Mono<ChannelOperations<?, ?>>) cachedConfiguration.connect(b); return ByteBufFlux.fromInbound(connector.flatMapMany(contentReceiver), alloc); }
static ByteBufFlux content(TcpClient cachedConfiguration, Function<ChannelOperations<?, ?>, Publisher<ByteBuf>> contentReceiver) { Bootstrap b; try { b = cachedConfiguration.configure(); } catch (Throwable t) { Exceptions.throwIfFatal(t); return ByteBufFlux.fromInbound(Mono.error(t)); } @SuppressWarnings("unchecked") ByteBufAllocator alloc = (ByteBufAllocator) b.config() .options() .getOrDefault(ChannelOption.ALLOCATOR, ByteBufAllocator.DEFAULT); @SuppressWarnings("unchecked") Mono<ChannelOperations<?, ?>> connector = (Mono<ChannelOperations<?, ?>>) cachedConfiguration.connect(b); return ByteBufFlux.fromInbound(connector.flatMapMany(contentReceiver), alloc); }
@Test public void testIssue303() { DisposableServer server = HttpServer.create() .port(0) .handle((req, resp) -> resp.sendString(Mono.just("OK"))) .wiretap(true) .bindNow(); Mono<String> content = createHttpClientForContextWithPort(server) .request(HttpMethod.GET) .uri("/") .send(ByteBufFlux.fromInbound(Mono.defer(() -> Mono.just("Hello".getBytes(Charset.defaultCharset()))))) .responseContent() .aggregate() .asString(); StepVerifier.create(content) .expectNextMatches("OK"::equals) .expectComplete() .verify(Duration.ofSeconds(30)); server.disposeNow(); }