/** * Aggregates this request. The returned {@link CompletableFuture} will be notified when the content and * the trailing headers of the request is received fully. */ default CompletableFuture<AggregatedHttpMessage> aggregate() { final CompletableFuture<AggregatedHttpMessage> future = new CompletableFuture<>(); final HttpRequestAggregator aggregator = new HttpRequestAggregator(this, future, null); completionFuture().handle(aggregator); subscribe(aggregator); return future; }
/** * Aggregates this request. The returned {@link CompletableFuture} will be notified when the content and * the trailing headers of the request is received fully. {@link AggregatedHttpMessage#content()} will * return a pooled object, and the caller must ensure to release it. If you don't know what this means, * use {@link #aggregate()}. */ default CompletableFuture<AggregatedHttpMessage> aggregateWithPooledObjects(ByteBufAllocator alloc) { requireNonNull(alloc, "alloc"); final CompletableFuture<AggregatedHttpMessage> future = new CompletableFuture<>(); final HttpRequestAggregator aggregator = new HttpRequestAggregator(this, future, alloc); completionFuture().handle(aggregator); subscribe(aggregator, true); return future; }
/** * Aggregates this request. The returned {@link CompletableFuture} will be notified when the content and * the trailing headers of the request is received fully. */ default CompletableFuture<AggregatedHttpMessage> aggregate(EventExecutor executor) { requireNonNull(executor, "executor"); final CompletableFuture<AggregatedHttpMessage> future = new CompletableFuture<>(); final HttpRequestAggregator aggregator = new HttpRequestAggregator(this, future, null); completionFuture().handleAsync(aggregator, executor); subscribe(aggregator, executor); return future; }
/** * Aggregates this request. The returned {@link CompletableFuture} will be notified when the content and * the trailing headers of the request is received fully. {@link AggregatedHttpMessage#content()} will * return a pooled object, and the caller must ensure to release it. If you don't know what this means, * use {@link #aggregate()}. */ default CompletableFuture<AggregatedHttpMessage> aggregateWithPooledObjects( EventExecutor executor, ByteBufAllocator alloc) { requireNonNull(executor, "executor"); requireNonNull(alloc, "alloc"); final CompletableFuture<AggregatedHttpMessage> future = new CompletableFuture<>(); final HttpRequestAggregator aggregator = new HttpRequestAggregator(this, future, alloc); completionFuture().handleAsync(aggregator, executor); subscribe(aggregator, executor, true); return future; } }
@Override public boolean invoke(ClientRequestContext ctx, HttpRequest req, DecodedHttpResponse res) { if (handleEarlyCancellation(ctx, req, res)) { return true; } final long writeTimeoutMillis = ctx.writeTimeoutMillis(); final long responseTimeoutMillis = ctx.responseTimeoutMillis(); final long maxContentLength = ctx.maxResponseLength(); assert responseDecoder != null; assert requestEncoder != null; final int numRequestsSent = ++this.numRequestsSent; final HttpResponseWrapper wrappedRes = responseDecoder.addResponse(numRequestsSent, req, res, ctx.logBuilder(), responseTimeoutMillis, maxContentLength); req.subscribe( new HttpRequestSubscriber(channel, requestEncoder, numRequestsSent, req, wrappedRes, ctx, writeTimeoutMillis), channel.eventLoop(), true); if (numRequestsSent >= MAX_NUM_REQUESTS_SENT) { responseDecoder.disconnectWhenFinished(); return false; } else { return true; } }
if (call != null) { ctx.setRequestTimeoutHandler(() -> call.close(Status.DEADLINE_EXCEEDED, EMPTY_METADATA)); req.subscribe(call.messageReader(), ctx.eventLoop(), true); req.completionFuture().handleAsync(call.messageReader(), ctx.eventLoop());
if (call != null) { ctx.setRequestTimeoutHandler(() -> call.close(Status.DEADLINE_EXCEEDED, EMPTY_METADATA)); req.subscribe(call.messageReader(), ctx.eventLoop(), true); req.completionFuture().handleAsync(call.messageReader(), ctx.eventLoop());