@Override public String toString() { return "NettyResponseFuture{" + // "currentRetry=" + currentRetry + // ",\n\tisDone=" + isDone + // ",\n\tisCancelled=" + isCancelled + // ",\n\tasyncHandler=" + asyncHandler + // ",\n\tnettyRequest=" + nettyRequest + // ",\n\tfuture=" + future + // ",\n\turi=" + getUri() + // ",\n\tkeepAlive=" + keepAlive + // ",\n\tredirectCount=" + redirectCount + // ",\n\ttimeoutsHolder=" + TIMEOUTS_HOLDER_FIELD.get(this) + // ",\n\tinAuth=" + inAuth + // ",\n\ttouch=" + touch + // '}'; } }
/** * Return true if the {@link Future} can be recovered. There is some scenario * where a connection can be closed by an unexpected IOException, and in some * situation we can recover from that exception. * * @return true if that {@link Future} cannot be recovered. */ public boolean isReplayPossible() { return !isDone() && !(Channels.isChannelActive(channel) && !getUri().getScheme().equalsIgnoreCase("https")) && inAuth == 0 && inProxyAuth == 0; }
public void onFailure(Channel channel, Throwable cause) { // beware, channel can be null Channels.silentlyCloseChannel(channel); boolean canRetry = future.incrementRetryAndCheck(); LOGGER.debug("Trying to recover from failing to connect channel {} with a retry value of {} ", channel, canRetry); if (canRetry// && cause != null // FIXME when can we have a null cause? && (future.getChannelState() != ChannelState.NEW || StackTraceInspector.recoverOnNettyDisconnectException(cause))) { if (requestSender.retry(future)) { return; } } LOGGER.debug("Failed to recover from connect exception: {} with channel {}", cause, channel); String message = cause.getMessage() != null ? cause.getMessage() : future.getUri().getBaseUrl(); ConnectException e = new ConnectException(message); e.initCause(cause); future.abort(e); } }
HttpResponseStatus status = new NettyResponseStatus(future.getUri(), response, channel); HttpHeaders responseHeaders = response.headers();
private void handleHttpResponse(final HttpResponse response, final Channel channel, final NettyResponseFuture<?> future, AsyncHandler<?> handler) throws Exception { HttpRequest httpRequest = future.getNettyRequest().getHttpRequest(); logger.debug("\n\nRequest {}\n\nResponse {}\n", httpRequest, response); future.setKeepAlive(config.getKeepAliveStrategy().keepAlive(future.getTargetRequest(), httpRequest, response)); NettyResponseStatus status = new NettyResponseStatus(future.getUri(), response, channel); HttpHeaders responseHeaders = response.headers(); if (!interceptors.exitAfterIntercept(channel, future, handler, response, status, responseHeaders)) { boolean abort = abortAfterHandlingStatus(handler, status) || // abortAfterHandlingHeaders(handler, responseHeaders) || // abortAfterHandlingReactiveStreams(channel, future, handler); if (abort) { finishUpdate(future, channel, true); } } }
Uri newUri = Uri.create(future.getUri(), location);
@Override public String toString() { return "NettyResponseFuture{" + // "currentRetry=" + currentRetry + // ",\n\tisDone=" + isDone + // ",\n\tisCancelled=" + isCancelled + // ",\n\tasyncHandler=" + asyncHandler + // ",\n\tnettyRequest=" + nettyRequest + // ",\n\tcontent=" + content + // ",\n\turi=" + getUri() + // ",\n\tkeepAlive=" + keepAlive + // ",\n\thttpHeaders=" + httpHeaders + // ",\n\texEx=" + exEx + // ",\n\tredirectCount=" + redirectCount + // ",\n\ttimeoutsHolder=" + timeoutsHolder + // ",\n\tinAuth=" + inAuth + // ",\n\tstatusReceived=" + statusReceived + // ",\n\ttouch=" + touch + // '}'; } }
@Override public String toString() { return "NettyResponseFuture{" + // "currentRetry=" + currentRetry + // ",\n\tisDone=" + isDone + // ",\n\tisCancelled=" + isCancelled + // ",\n\tasyncHandler=" + asyncHandler + // ",\n\tnettyRequest=" + nettyRequest + // ",\n\tcontent=" + content + // ",\n\turi=" + getUri() + // ",\n\tkeepAlive=" + keepAlive + // ",\n\thttpHeaders=" + httpHeaders + // ",\n\texEx=" + exEx + // ",\n\tredirectCount=" + redirectCount + // ",\n\ttimeoutsHolder=" + timeoutsHolder + // ",\n\tinAuth=" + inAuth + // ",\n\tstatusReceived=" + statusReceived + // ",\n\ttouch=" + touch + // '}'; } }
/** * Return true if the {@link Future} can be recovered. There is some scenario where a connection can be closed by an * unexpected IOException, and in some situation we can recover from that exception. * * @return true if that {@link Future} cannot be recovered. */ public boolean canBeReplayed() { return !isDone() && canRetry() && !(Channels.isChannelValid(channel) && !getUri().getScheme().equalsIgnoreCase("https")) && !isInAuth(); }
/** * Return true if the {@link Future} can be recovered. There is some scenario where a connection can be closed by an * unexpected IOException, and in some situation we can recover from that exception. * * @return true if that {@link Future} cannot be recovered. */ public boolean canBeReplayed() { return !isDone() && canRetry() && !(Channels.isChannelValid(channel) && !getUri().getScheme().equalsIgnoreCase("https")) && !isInAuth(); }
private void onFutureFailure(Channel channel, Throwable cause) { abortChannelPreemption(); boolean canRetry = future.canRetry(); LOGGER.debug("Trying to recover from failing to connect channel {} with a retry value of {} ", channel, canRetry); if (canRetry && cause != null && (future.getState() != NettyResponseFuture.STATE.NEW || StackTraceInspector.recoverOnNettyDisconnectException(cause))) { if (requestSender.retry(future)) return; } LOGGER.debug("Failed to recover from connect exception: {} with channel {}", cause, channel); boolean printCause = cause != null && cause.getMessage() != null; String printedCause = printCause ? cause.getMessage() : getBaseUrl(future.getUri()); ConnectException e = new ConnectException(printedCause); if (cause != null) { e.initCause(cause); } future.abort(e); }
private void onFutureFailure(Channel channel, Throwable cause) { abortChannelPreemption(); boolean canRetry = future.canRetry(); LOGGER.debug("Trying to recover from failing to connect channel {} with a retry value of {} ", channel, canRetry); if (canRetry// && cause != null// && (future.getState() != NettyResponseFuture.STATE.NEW || StackTraceInspector.recoverOnNettyDisconnectException(cause))) { if (requestSender.retry(future)) { return; } } LOGGER.debug("Failed to recover from connect exception: {} with channel {}", cause, channel); boolean printCause = cause != null && cause.getMessage() != null; String printedCause = printCause ? cause.getMessage() : getBaseUrl(future.getUri()); ConnectException e = new ConnectException(printedCause); if (cause != null) e.initCause(cause); future.abort(e); }
private void onFutureFailure(Channel channel, Throwable cause) { abortChannelPreemption(); boolean canRetry = future.canRetry(); LOGGER.debug("Trying to recover from failing to connect channel {} with a retry value of {} ", channel, canRetry); if (canRetry && cause != null && (future.getState() != NettyResponseFuture.STATE.NEW || StackTraceInspector.recoverOnNettyDisconnectException(cause))) { if (requestSender.retry(future)) return; } LOGGER.debug("Failed to recover from connect exception: {} with channel {}", cause, channel); boolean printCause = cause != null && cause.getMessage() != null; String printedCause = printCause ? cause.getMessage() : getBaseUrl(future.getUri()); ConnectException e = new ConnectException(printedCause); if (cause != null) { e.initCause(cause); } future.abort(e); }
private void onFutureFailure(Channel channel, Throwable cause) { abortChannelPreemption(); boolean canRetry = future.canRetry(); LOGGER.debug("Trying to recover from failing to connect channel {} with a retry value of {} ", channel, canRetry); if (canRetry// && cause != null// && (future.getState() != NettyResponseFuture.STATE.NEW || StackTraceInspector.recoverOnNettyDisconnectException(cause))) { if (requestSender.retry(future)) { return; } } LOGGER.debug("Failed to recover from connect exception: {} with channel {}", cause, channel); boolean printCause = cause != null && cause.getMessage() != null; String printedCause = printCause ? cause.getMessage() : getBaseUrl(future.getUri()); ConnectException e = new ConnectException(printedCause); if (cause != null) e.initCause(cause); future.abort(e); }
Request request = future.getRequest(); HttpResponseStatus status = new NettyResponseStatus(future.getUri(), config, response, channel); HttpResponseHeaders responseHeaders = new NettyResponseHeaders(response.headers()); Realm realm = request.getRealm() != null ? request.getRealm() : config.getRealm();
Request request = future.getRequest(); HttpResponseStatus status = new NettyResponseStatus(future.getUri(), config, response, channel); HttpResponseHeaders responseHeaders = new NettyResponseHeaders(response.headers()); Realm realm = request.getRealm() != null ? request.getRealm() : config.getRealm();
private boolean handleHttpResponse(final HttpResponse response, final Channel channel, final NettyResponseFuture<?> future, AsyncHandler<?> handler) throws Exception { HttpRequest httpRequest = future.getNettyRequest().getHttpRequest(); ProxyServer proxyServer = future.getProxyServer(); logger.debug("\n\nRequest {}\n\nResponse {}\n", httpRequest, response); // store the original headers so we can re-send all them to // the handler in case of trailing headers future.setHttpHeaders(response.headers()); future.setKeepAlive(connectionStrategy.keepAlive(httpRequest, response)); NettyResponseStatus status = new NettyResponseStatus(future.getUri(), config, response, channel); int statusCode = response.getStatus().code(); Request request = future.getRequest(); Realm realm = request.getRealm() != null ? request.getRealm() : config.getRealm(); NettyResponseHeaders responseHeaders = new NettyResponseHeaders(response.headers()); return exitAfterProcessingFilters(channel, future, handler, status, responseHeaders) || exitAfterHandling401(channel, future, response, request, statusCode, realm, proxyServer) || // exitAfterHandling407(channel, future, response, request, statusCode, realm, proxyServer) || // exitAfterHandling100(channel, future, statusCode) || // exitAfterHandlingRedirect(channel, future, response, request, statusCode, realm) || // exitAfterHandlingConnect(channel, future, request, proxyServer, statusCode, httpRequest) || // exitAfterHandlingStatus(channel, future, response, handler, status) || // exitAfterHandlingHeaders(channel, future, response, handler, responseHeaders); }
private boolean handleHttpResponse(final HttpResponse response, final Channel channel, final NettyResponseFuture<?> future, AsyncHandler<?> handler) throws Exception { HttpRequest httpRequest = future.getNettyRequest().getHttpRequest(); ProxyServer proxyServer = future.getProxyServer(); logger.debug("\n\nRequest {}\n\nResponse {}\n", httpRequest, response); // store the original headers so we can re-send all them to // the handler in case of trailing headers future.setHttpHeaders(response.headers()); future.setKeepAlive(connectionStrategy.keepAlive(httpRequest, response)); NettyResponseStatus status = new NettyResponseStatus(future.getUri(), config, response, channel); int statusCode = response.getStatus().code(); Request request = future.getRequest(); Realm realm = request.getRealm() != null ? request.getRealm() : config.getRealm(); NettyResponseHeaders responseHeaders = new NettyResponseHeaders(response.headers()); return exitAfterProcessingFilters(channel, future, handler, status, responseHeaders) || exitAfterHandling401(channel, future, response, request, statusCode, realm, proxyServer) || // exitAfterHandling407(channel, future, response, request, statusCode, realm, proxyServer) || // exitAfterHandling100(channel, future, statusCode) || // exitAfterHandlingRedirect(channel, future, response, request, statusCode, realm) || // exitAfterHandlingConnect(channel, future, request, proxyServer, statusCode, httpRequest) || // exitAfterHandlingStatus(channel, future, response, handler, status) || // exitAfterHandlingHeaders(channel, future, response, handler, responseHeaders) || exitAfterHandlingReactiveStreams(channel, future, response, handler); }
private boolean handleHttpResponse(final HttpResponse response,// final Channel channel,// final NettyResponseFuture<?> future,// AsyncHandler<?> handler) throws Exception { HttpRequest httpRequest = future.getNettyRequest().getHttpRequest(); ProxyServer proxyServer = future.getProxyServer(); logger.debug("\n\nRequest {}\n\nResponse {}\n", httpRequest, response); // store the original headers so we can re-send all them to // the handler in case of trailing headers future.setHttpHeaders(response.headers()); future.setKeepAlive(connectionStrategy.keepAlive(httpRequest, response)); NettyResponseStatus status = new NettyResponseStatus(future.getUri(), config, response, channel); int statusCode = response.getStatus().getCode(); Request request = future.getRequest(); Realm realm = request.getRealm() != null ? request.getRealm() : config.getRealm(); NettyResponseHeaders responseHeaders = new NettyResponseHeaders(response.headers()); return exitAfterProcessingFilters(channel, future, handler, status, responseHeaders) || exitAfterHandling401(channel, future, response, request, statusCode, realm, proxyServer) || // exitAfterHandling407(channel, future, response, request, statusCode, realm, proxyServer) || // exitAfterHandling100(channel, future, statusCode) || // exitAfterHandlingRedirect(channel, future, response, request, statusCode, realm) || // exitAfterHandlingConnect(channel, future, request, proxyServer, statusCode, httpRequest) || // exitAfterHandlingStatus(channel, future, response, handler, status) || // exitAfterHandlingHeaders(channel, future, response, handler, responseHeaders) || // exitAfterHandlingBody(channel, future, response, handler); }
private boolean handleHttpResponse(final HttpResponse response,// final Channel channel,// final NettyResponseFuture<?> future,// AsyncHandler<?> handler) throws Exception { HttpRequest httpRequest = future.getNettyRequest().getHttpRequest(); ProxyServer proxyServer = future.getProxyServer(); logger.debug("\n\nRequest {}\n\nResponse {}\n", httpRequest, response); // store the original headers so we can re-send all them to // the handler in case of trailing headers future.setHttpHeaders(response.headers()); future.setKeepAlive(connectionStrategy.keepAlive(httpRequest, response)); NettyResponseStatus status = new NettyResponseStatus(future.getUri(), config, response, channel); int statusCode = response.getStatus().getCode(); Request request = future.getRequest(); Realm realm = request.getRealm() != null ? request.getRealm() : config.getRealm(); NettyResponseHeaders responseHeaders = new NettyResponseHeaders(response.headers()); return exitAfterProcessingFilters(channel, future, handler, status, responseHeaders) || exitAfterHandling401(channel, future, response, request, statusCode, realm, proxyServer) || // exitAfterHandling407(channel, future, response, request, statusCode, realm, proxyServer) || // exitAfterHandling100(channel, future, statusCode) || // exitAfterHandlingRedirect(channel, future, response, request, statusCode, realm) || // exitAfterHandlingConnect(channel, future, request, proxyServer, statusCode, httpRequest) || // exitAfterHandlingStatus(channel, future, response, handler, status) || // exitAfterHandlingHeaders(channel, future, response, handler, responseHeaders) || // exitAfterHandlingBody(channel, future, response, handler); }