当前位置: 首页>>代码示例>>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;未经允许,请勿转载。