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


Java HttpUriRequest.getMethod方法代碼示例

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


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

示例1: args

import org.apache.http.client.methods.HttpUriRequest; //導入方法依賴的package包/類
/**
 * 攔截HttpClient的Post與Get方法.
 * 
 */
@Around("execution(* org.apache.http.client.HttpClient.execute(..)) && args(httpUriRequest)")
public Object around(final ProceedingJoinPoint proceedingJoinPoint, final HttpUriRequest httpUriRequest)
    throws Throwable {
  final long startTime = System.currentTimeMillis();
  final Object[] args = proceedingJoinPoint.getArgs();
  final Object result = proceedingJoinPoint.proceed(args);

  if (httpUriRequest instanceof HttpUriRequest) {
    final String methodName = httpUriRequest.getMethod();
    final String className = httpUriRequest.getURI().toString();

    Tracer.getInstance().addBinaryAnnotation(className, methodName, (int) (System.currentTimeMillis() - startTime));
  }

  return result;
}
 
開發者ID:junzixiehui,項目名稱:godeye,代碼行數:21,代碼來源:HttpClientAop.java

示例2: retryRequest

import org.apache.http.client.methods.HttpUriRequest; //導入方法依賴的package包/類
@Override
public boolean retryRequest(IOException exception, int executionCount, HttpContext context) {
    boolean retry = true;

    Boolean b = (Boolean) context.getAttribute(ExecutionContext.HTTP_REQ_SENT);
    boolean sent = (b != null && b);

    if (executionCount > maxRetries) {
        // Do not retry if over max retry count
        retry = false;
    } else if (isInList(exceptionBlacklist, exception)) {
        // immediately cancel retry if the error is blacklisted
        retry = false;
    } else if (isInList(exceptionWhitelist, exception)) {
        // immediately retry if error is whitelisted
        retry = true;
    } else if (!sent) {
        // for most other errors, retry only if request hasn't been fully sent yet
        retry = true;
    }

    if (retry) {
        // resend all idempotent requests
        HttpUriRequest currentReq = (HttpUriRequest) context.getAttribute(ExecutionContext.HTTP_REQUEST);
        if (currentReq == null) {
            return false;
        }
        String requestType = currentReq.getMethod();
        retry = !requestType.equals("POST");
    }

    if (retry) {
        SystemClock.sleep(retrySleepTimeMS);
    } else {
        exception.printStackTrace();
    }

    return retry;
}
 
開發者ID:LanguidSheep,項目名稱:sealtalk-android-master,代碼行數:40,代碼來源:RetryHandler.java


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