ArmeriaHttpClientResponseSubscriber(HttpResponse httpResponse) { httpResponse.completionFuture().whenComplete(this); httpResponse.subscribe(this, eventLoop); }
/** * Aggregates this response. The returned {@link CompletableFuture} will be notified when the content and * the trailing headers of the response are received fully. */ default CompletableFuture<AggregatedHttpMessage> aggregate() { final CompletableFuture<AggregatedHttpMessage> future = new CompletableFuture<>(); final HttpResponseAggregator aggregator = new HttpResponseAggregator(future, null); completionFuture().handle(aggregator); subscribe(aggregator); return future; }
/** * Aggregates this response. The returned {@link CompletableFuture} will be notified when the content and * the trailing headers of the response are 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 HttpResponseAggregator aggregator = new HttpResponseAggregator(future, alloc); completionFuture().handle(aggregator); subscribe(aggregator, true); return future; }
@Override public void enqueue(Callback callback) { createRequest(); httpResponse.subscribe(callFactory.subscriberFactory.create(this, callback, request)); }
/** * Aggregates this response. 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 HttpResponseAggregator aggregator = new HttpResponseAggregator(future, alloc); completionFuture().handleAsync(aggregator, executor); subscribe(aggregator, executor, true); return future; } }
/** * Aggregates this response. The returned {@link CompletableFuture} will be notified when the content and * the trailing headers of the response are received fully. */ default CompletableFuture<AggregatedHttpMessage> aggregate(EventExecutor executor) { final CompletableFuture<AggregatedHttpMessage> future = new CompletableFuture<>(); final HttpResponseAggregator aggregator = new HttpResponseAggregator(future, null); completionFuture().handleAsync(aggregator, executor); subscribe(aggregator, executor); return future; }
AtomicReference<Throwable> error = new AtomicReference<>(); client.get("/trailers").subscribe(new Subscriber<HttpObject>() { @Override public void onSubscribe(Subscription s) {
AtomicReference<Throwable> error = new AtomicReference<>(); client.get("/trailers-only").subscribe(new Subscriber<HttpObject>() { @Override public void onSubscribe(Subscription s) {
final HttpClient client = HttpClient.of(rule.uri("/streaming")); final AtomicBoolean isFinished = new AtomicBoolean(); client.get("/json").subscribe(new DefaultSubscriber<HttpObject>() { final ImmutableList.Builder<HttpObject> received = new Builder<>();
new HttpResponseSubscriber(ctx, responseEncoder, reqCtx, req, accessLogWriter); reqCtx.setRequestTimeoutChangeListener(resSubscriber); res.subscribe(resSubscriber, eventLoop, true);
@Override public void start(Listener<O> responseListener, Metadata unused) { requireNonNull(responseListener, "responseListener"); final Compressor compressor; if (callOptions.getCompressor() != null) { compressor = compressorRegistry.lookupCompressor(callOptions.getCompressor()); if (compressor == null) { responseListener.onClose( Status.INTERNAL.withDescription( "Unable to find compressor by name " + callOptions.getCompressor()), EMPTY_METADATA); return; } } else { compressor = Identity.NONE; } messageFramer.setCompressor(compressor); prepareHeaders(req.headers(), compressor); listener = responseListener; final HttpResponse res; try (SafeCloseable ignored = ctx.push()) { res = httpClient.execute(ctx, req); } catch (Exception e) { close(Status.fromThrowable(e)); return; } res.subscribe(responseReader, ctx.eventLoop(), true); res.completionFuture().handleAsync(responseReader, ctx.eventLoop()); }
@Override public void start(Listener<O> responseListener, Metadata unused) { requireNonNull(responseListener, "responseListener"); final Compressor compressor; if (callOptions.getCompressor() != null) { compressor = compressorRegistry.lookupCompressor(callOptions.getCompressor()); if (compressor == null) { responseListener.onClose( Status.INTERNAL.withDescription( "Unable to find compressor by name " + callOptions.getCompressor()), EMPTY_METADATA); return; } } else { compressor = Identity.NONE; } messageFramer.setCompressor(compressor); prepareHeaders(req.headers(), compressor); listener = responseListener; final HttpResponse res; try (SafeCloseable ignored = ctx.push()) { res = httpClient.execute(ctx, req); } catch (Exception e) { close(Status.fromThrowable(e)); return; } res.subscribe(responseReader, ctx.eventLoop(), true); res.completionFuture().handleAsync(responseReader, ctx.eventLoop()); }