List of usage examples for org.apache.http.protocol HttpCoreContext HTTP_REQ_SENT
String HTTP_REQ_SENT
To view the source code for org.apache.http.protocol HttpCoreContext HTTP_REQ_SENT.
Click Source Link
From source file:com.normalexception.app.rx8club.httpclient.RetryHandler.java
public boolean retryRequest(IOException exception, int executionCount, HttpContext context) { // retry a max of MAX_RETRY times if (executionCount >= MAX_RETRY) { Log.d(TAG, "Max Retries Exceeded"); return false; }/*from www. j a v a2s .com*/ if (exception instanceof NoHttpResponseException) { // Retry if the server dropped connection on us Log.d(TAG, "Server dropped request, retrying"); return true; } Boolean b = (Boolean) context.getAttribute(HttpCoreContext.HTTP_REQ_SENT); boolean sent = (b != null && b.booleanValue()); if (!sent) { // Retry if the request has not been sent fully or // if it's OK to retry methods that have been sent Log.d(TAG, "Request not fully sent, retrying"); return true; } // otherwise do not retry return false; }
From source file:com.mxhero.plugin.cloudstorage.onedrive.api.command.HttpRequestRetryHandler.java
@Override public boolean retryRequest(IOException exception, int executionCount, HttpContext context) { if (executionCount >= retries) { logger.debug("no more retries, cancel"); return false; }//from w ww . j av a 2s .co m if (exception instanceof NoHttpResponseException) { logger.debug("is NoHttpResponseException, retrying..."); return true; } if (exception instanceof ConnectTimeoutException || exception instanceof ConnectionPoolTimeoutException) { logger.debug("is ConnectTimeoutException or ConnectionPoolTimeoutException, retrying..."); return true; } if (exception instanceof InterruptedIOException) { logger.debug("is InterruptedIOException, retrying..."); return true; } if (exception instanceof UnknownHostException) { logger.debug("is UnknownHostException, cancel"); return false; } if (exception instanceof ConnectException) { logger.debug("is ConnectException, cancel"); return false; } if (exception instanceof SSLException) { logger.debug("is SSLException, cancel"); return false; } HttpRequest request = (HttpRequest) context.getAttribute(HttpCoreContext.HTTP_REQUEST); boolean idempotent = !(request instanceof HttpEntityEnclosingRequest); if (idempotent) { logger.debug("is idempotent, retrying..."); return true; } Boolean b = (Boolean) context.getAttribute(HttpCoreContext.HTTP_REQ_SENT); boolean sent = (b != null && b.booleanValue()); if (!sent) { logger.debug("is not sent, retrying..."); return true; } return false; }
From source file:org.apache.http.impl.client.cache.CachingHttpAsyncClient.java
private void handleCacheHit(final BasicFuture<HttpResponse> future, final HttpHost target, final HttpRequestWrapper request, final HttpCacheContext clientContext, final HttpCacheEntry entry) throws IOException { recordCacheHit(target, request);/* www . ja v a 2 s . com*/ final HttpResponse out; final Date now = getCurrentDate(); if (this.suitabilityChecker.canCachedResponseBeUsed(target, request, entry, now)) { log.debug("Cache hit"); out = generateCachedResponse(request, clientContext, entry, now); } else if (!mayCallBackend(request)) { log.debug("Cache entry not suitable but only-if-cached requested"); out = generateGatewayTimeout(clientContext); } else if (validityPolicy.isRevalidatable(entry) && !(entry.getStatusCode() == HttpStatus.SC_NOT_MODIFIED && !suitabilityChecker.isConditional(request))) { log.debug("Revalidating cache entry"); revalidateCacheEntry(future, target, request, clientContext, entry, now); return; } else { log.debug("Cache entry not usable; calling backend"); callBackend(future, target, request, clientContext); return; } clientContext.setAttribute(HttpClientContext.HTTP_ROUTE, new HttpRoute(target)); clientContext.setAttribute(HttpCoreContext.HTTP_TARGET_HOST, target); clientContext.setAttribute(HttpCoreContext.HTTP_REQUEST, request); clientContext.setAttribute(HttpCoreContext.HTTP_RESPONSE, out); clientContext.setAttribute(HttpCoreContext.HTTP_REQ_SENT, Boolean.TRUE); future.completed(out); }