當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpClientContext.isRequestSent方法代碼示例

本文整理匯總了Java中org.apache.http.client.protocol.HttpClientContext.isRequestSent方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpClientContext.isRequestSent方法的具體用法?Java HttpClientContext.isRequestSent怎麽用?Java HttpClientContext.isRequestSent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.http.client.protocol.HttpClientContext的用法示例。


在下文中一共展示了HttpClientContext.isRequestSent方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: retryRequest

import org.apache.http.client.protocol.HttpClientContext; //導入方法依賴的package包/類
/**
 * Used <code>retryCount</code> and <code>requestSentRetryEnabled</code> to determine
 * if the given method should be retried.
 */
public boolean retryRequest(
        final IOException exception,
        final int executionCount,
        final HttpContext context) {
    Args.notNull(exception, "Exception parameter");
    Args.notNull(context, "HTTP context");
    if (executionCount > this.retryCount) {
        // Do not retry if over max retry count
        return false;
    }
    if (this.nonRetriableClasses.contains(exception.getClass())) {
        return false;
    } else {
        for (final Class<? extends IOException> rejectException : this.nonRetriableClasses) {
            if (rejectException.isInstance(exception)) {
                return false;
            }
        }
    }
    final HttpClientContext clientContext = HttpClientContext.adapt(context);
    final HttpRequest request = clientContext.getRequest();

    if(requestIsAborted(request)){
        return false;
    }

    if (handleAsIdempotent(request)) {
        // Retry if the request is considered idempotent
        return true;
    }

    if (!clientContext.isRequestSent() || this.requestSentRetryEnabled) {
        // Retry if the request has not been sent fully or
        // if it's OK to retry methods that have been sent
        return true;
    }
    // otherwise do not retry
    return false;
}
 
開發者ID:xxonehjh,項目名稱:remote-files-sync,代碼行數:44,代碼來源:DefaultHttpRequestRetryHandlerHC4.java

示例2: retryRequest

import org.apache.http.client.protocol.HttpClientContext; //導入方法依賴的package包/類
/**
 * Used {@code retryCount} and {@code requestSentRetryEnabled} to determine
 * if the given method should be retried.
 */
@Override
public boolean retryRequest(
        final IOException exception,
        final int executionCount,
        final HttpContext context) {
    Args.notNull(exception, "Exception parameter");
    Args.notNull(context, "HTTP context");
    if (executionCount > this.retryCount) {
        // Do not retry if over max retry count
        return false;
    }
    if (this.nonRetriableClasses.contains(exception.getClass())) {
        return false;
    } else {
        for (final Class<? extends IOException> rejectException : this.nonRetriableClasses) {
            if (rejectException.isInstance(exception)) {
                return false;
            }
        }
    }
    final HttpClientContext clientContext = HttpClientContext.adapt(context);
    final HttpRequest request = clientContext.getRequest();

    if(requestIsAborted(request)){
        return false;
    }

    if (handleAsIdempotent(request)) {
        // Retry if the request is considered idempotent
        return true;
    }

    if (!clientContext.isRequestSent() || this.requestSentRetryEnabled) {
        // Retry if the request has not been sent fully or
        // if it's OK to retry methods that have been sent
        return true;
    }
    // otherwise do not retry
    return false;
}
 
開發者ID:MyPureCloud,項目名稱:purecloud-iot,代碼行數:45,代碼來源:DefaultHttpRequestRetryHandler.java


注:本文中的org.apache.http.client.protocol.HttpClientContext.isRequestSent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。