@Override public Mono<ClientHttpResponse> connect(HttpMethod method, URI uri, Function<? super ClientHttpRequest, Mono<Void>> requestCallback) { if (!uri.isAbsolute()) { return Mono.error(new IllegalArgumentException("URI is not absolute: " + uri)); } return this.httpClient .request(io.netty.handler.codec.http.HttpMethod.valueOf(method.name())) .uri(uri.toString()) .send((request, outbound) -> requestCallback.apply(adaptRequest(method, uri, request, outbound))) .responseConnection((res, con) -> Mono.just(adaptResponse(res, con.inbound(), con.outbound().alloc()))) .next(); }
@Override public Mono<ClientHttpResponse> connect(HttpMethod method, URI uri, Function<? super ClientHttpRequest, Mono<Void>> requestCallback) { if (!uri.isAbsolute()) { return Mono.error(new IllegalArgumentException("URI is not absolute: " + uri)); } return this.httpClient .request(io.netty.handler.codec.http.HttpMethod.valueOf(method.name())) .uri(uri.toString()) .send((request, outbound) -> requestCallback.apply(adaptRequest(method, uri, request, outbound))) .responseConnection((res, con) -> Mono.just(adaptResponse(res, con.inbound(), con.outbound().alloc()))) .next(); }
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(); }
@Override public Mono<ClientHttpResponse> connect(HttpMethod method, URI uri, Function<? super ClientHttpRequest, Mono<Void>> requestCallback) { if (!uri.isAbsolute()) { return Mono.error(new IllegalArgumentException("URI is not absolute: " + uri)); } return this.httpClient .request(io.netty.handler.codec.http.HttpMethod.valueOf(method.name())) .uri(uri.toString()) .send((request, outbound) -> requestCallback.apply(adaptRequest(method, uri, request, outbound))) .responseConnection((res, con) -> Mono.just(adaptResponse(res, con.inbound(), con.outbound().alloc()))) .next(); }
this.codec = codec; this.connection = connection; this.outbound = (WebsocketOutbound) connection.outbound().options(SendOptions::flushOnEach);
@Override @SuppressWarnings("unchecked") public void onStateChange(Connection connection, State newState) { if (newState == State.CONFIGURED) { try { if (log.isDebugEnabled()) { log.debug(format(connection.channel(), "Handler is being applied: {}"), handler); } Mono.fromDirect(handler.apply(connection.inbound(), connection.outbound())) .subscribe(connection.disposeSubscriber()); } catch (Throwable t) { log.error(format(connection.channel(), ""), t); connection.channel() .close(); } } } }
@Override @SuppressWarnings("unchecked") public void onStateChange(Connection connection, State newState) { if (newState == State.CONFIGURED) { try { if (log.isDebugEnabled()) { log.debug(format(connection.channel(), "Handler is being applied: {}"), handler); } Mono.fromDirect(handler.apply(connection.inbound(), connection.outbound())) .subscribe(connection.disposeSubscriber()); } catch (Throwable t) { log.error(format(connection.channel(), ""), t); connection.channel() .close(); } } } }