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()); }
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 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<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(); }
@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 ByteBufAllocator alloc() { return source.alloc(); }
@Override public ByteBufAllocator alloc() { return source.alloc(); }
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 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); }
/** * Send String 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 * @param charset the encoding charset * * @return A Publisher to signal successful sequence write (e.g. after "flush") or any * error during write */ default NettyOutbound sendString(Publisher<? extends String> dataStream, Charset charset) { return sendObject(ReactorNetty.publisherOrScalarMap( dataStream, s -> { ByteBuf buffer = alloc().buffer(); buffer.writeCharSequence(s, charset); return buffer; })); }
/** * Send String 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 * @param charset the encoding charset * * @return A Publisher to signal successful sequence write (e.g. after "flush") or any * error during write */ default NettyOutbound sendString(Publisher<? extends String> dataStream, Charset charset) { return sendObject(ReactorNetty.publisherOrScalarMap( dataStream, s -> { ByteBuf buffer = alloc().buffer(); buffer.writeCharSequence(s, charset); return buffer; })); }
@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(); }
try (ByteArrayOutputStream os = new ByteArrayOutputStream()) { m.writeValue(os, s); return out.alloc() .buffer() .writeBytes(os.toByteArray());