@Override @SuppressWarnings("deprecation") public void onReadInactivity(Runnable runnable, long inactivityDuration) { this.inbound.withConnection(conn -> conn.onReadIdle(inactivityDuration, runnable)); }
@Override @SuppressWarnings("deprecation") public void onWriteInactivity(Runnable runnable, long inactivityDuration) { this.inbound.withConnection(conn -> conn.onWriteIdle(inactivityDuration, runnable)); }
@Override protected Mono<Void> writeAndFlushWithInternal(Publisher<? extends Publisher<? extends DataBuffer>> publisher) { return this.response.sendGroups(Flux.from(publisher).map(this::toByteBufs)).then(); }
@Override public Mono<Void> writeAndFlushWith(Publisher<? extends Publisher<? extends DataBuffer>> body) { Publisher<Publisher<ByteBuf>> byteBufs = Flux.from(body).map(ReactorClientHttpRequest::toByteBufs); return doCommit(() -> this.outbound.sendGroups(byteBufs).then()); }
@Override @Nullable protected String initId() { return this.request instanceof Connection ? ((Connection) this.request).channel().id().asShortText() : null; }
public ReactorClientHttpRequest(HttpMethod method, URI uri, HttpClientRequest request, NettyOutbound outbound) { this.httpMethod = method; this.uri = uri; this.request = request; this.outbound = outbound; this.bufferFactory = new NettyDataBufferFactory(outbound.alloc()); }
@Override public Flux<DataBuffer> getBody() { return this.inbound.receive() .doOnSubscribe(s -> { if (this.rejectSubscribers.get()) { throw new IllegalStateException("The client response body can only be consumed once."); } }) .doOnCancel(() -> { // https://github.com/reactor/reactor-netty/issues/503 // FluxReceive rejects multiple subscribers, but not after a cancel(). // Subsequent subscribers after cancel() will not be rejected, but will hang instead. // So we need to intercept and reject them in that case. this.rejectSubscribers.set(true); }) .map(byteBuf -> { byteBuf.retain(); return this.bufferFactory.wrap(byteBuf); }); }
@Override protected void stopInternal() { this.serverRef.get().dispose(); }
@Override public void stop() throws WebServerException { if (this.disposableServer != null) { if (this.lifecycleTimeout != null) { this.disposableServer.disposeNow(this.lifecycleTimeout); } else { this.disposableServer.disposeNow(); } this.disposableServer = null; } }
@Override public int getPort() { if (this.disposableServer != null) { return this.disposableServer.port(); } return 0; }
public ReactorClientHttpRequest(HttpMethod method, URI uri, HttpClientRequest request, NettyOutbound outbound) { this.httpMethod = method; this.uri = uri; this.request = request; this.outbound = outbound; this.bufferFactory = new NettyDataBufferFactory(outbound.alloc()); }
@Override protected void stopInternal() { this.serverRef.get().dispose(); }