IOException e = new IOException("AsyncHttpClient has been closed."); asyncHandler.onThrowable(e); return new ListenableFuture.CompletedFailure<>(e);
IOException e = new IOException("AsyncHttpClient has been closed."); asyncHandler.onThrowable(e); return new ListenableFuture.CompletedFailure<>(e);
IOException e = new IOException("AsyncHttpClient has been closed."); asyncHandler.onThrowable(e); return new ListenableFuture.CompletedFailure<>(e);
/** * Execute an HTTP request. * * @param request {@link Request} * @param handler an instance of {@link AsyncHandler} * @param <T> Type of the value that will be returned by the associated {@link java.util.concurrent.Future} * @return a {@link Future} of type T */ public <T> ListenableFuture<T> executeRequest(Request request, AsyncHandler<T> handler) { if (config.getRequestFilters().isEmpty()) { return httpProvider.execute(request, handler); } else { FilterContext<T> fc = new FilterContext.FilterContextBuilder<T>().asyncHandler(handler).request(request).build(); try { fc = preProcessRequest(fc); } catch (Exception e) { handler.onThrowable(e); return new ListenableFuture.CompletedFailure<T>("preProcessRequest failed", e); } return httpProvider.execute(fc.getRequest(), fc.getAsyncHandler()); } }
/** * Execute an HTTP request. * * @param request {@link Request} * @param handler an instance of {@link AsyncHandler} * @param <T> Type of the value that will be returned by the associated {@link java.util.concurrent.Future} * @return a {@link Future} of type T */ public <T> ListenableFuture<T> executeRequest(Request request, AsyncHandler<T> handler) { if (config.getRequestFilters().isEmpty()) { return httpProvider.execute(request, handler); } else { FilterContext<T> fc = new FilterContext.FilterContextBuilder<T>().asyncHandler(handler).request(request).build(); try { fc = preProcessRequest(fc); } catch (Exception e) { handler.onThrowable(e); return new ListenableFuture.CompletedFailure<T>("preProcessRequest failed", e); } return httpProvider.execute(fc.getRequest(), fc.getAsyncHandler()); } }
/** * Execute an HTTP request. * * @param request {@link Request} * @param handler an instance of {@link AsyncHandler} * @param <T> Type of the value that will be returned by the associated {@link java.util.concurrent.Future} * @return a {@link Future} of type T */ public <T> ListenableFuture<T> executeRequest(Request request, AsyncHandler<T> handler) { if (config.getRequestFilters().isEmpty()) { return httpProvider.execute(request, handler); } else { FilterContext<T> fc = new FilterContext.FilterContextBuilder<T>().asyncHandler(handler).request(request).build(); try { fc = preProcessRequest(fc); } catch (Exception e) { handler.onThrowable(e); return new ListenableFuture.CompletedFailure<T>("preProcessRequest failed", e); } return httpProvider.execute(fc.getRequest(), fc.getAsyncHandler()); } }
public <T> ListenableFuture<T> execute(Request request, AsyncHandler<T> handler) { try { return execute(request, handler, null); } catch (IOException e) { handler.onThrowable(e); return new ListenableFuture.CompletedFailure<>(e); } }
@Override public <T> ListenableFuture<T> execute(Request request, final AsyncHandler<T> asyncHandler) { try { return requestSender.sendRequest(request, asyncHandler, null, false); } catch (Exception e) { asyncHandler.onThrowable(e); return new ListenableFuture.CompletedFailure<>(e); } }