Ejemplo n.º 1
0
  public HttpHandler<File> download(
      HttpRequest.HttpMethod method,
      String url,
      String target,
      RequestParams params,
      boolean autoResume,
      boolean autoRename,
      RequestCallBack<File> callback) {

    if (url == null) throw new IllegalArgumentException("url may not be null");
    if (target == null) throw new IllegalArgumentException("target may not be null");

    HttpRequest request = new HttpRequest(method, url);

    HttpHandler<File> handler =
        new HttpHandler<File>(httpClient, httpContext, responseTextCharset, callback);

    handler.setExpiry(currentRequestExpiry);
    handler.setHttpRedirectHandler(httpRedirectHandler);

    if (params != null) {
      request.setRequestParams(params, handler);
      handler.setPriority(params.getPriority());
    }
    handler.executeOnExecutor(EXECUTOR, request, target, autoResume, autoRename);
    return handler;
  }
Ejemplo n.º 2
0
  // //////////////////////////////////////////////////////////////////////////////////////////////
  private <T> HttpHandler<T> sendRequest(
      HttpRequest request, RequestParams params, RequestCallBack<T> callBack) {

    // liuzw. 增加安全加密步骤,加密过程可定制.
    if (secureInterceptor != null) {
      params = secureInterceptor.preSend(request, params);
    }

    HttpHandler<T> handler =
        new HttpHandler<T>(httpClient, httpContext, responseTextCharset, callBack);

    handler.setExpiry(currentRequestExpiry);
    handler.setHttpRedirectHandler(httpRedirectHandler);
    request.setRequestParams(params, handler);

    if (params != null) {
      handler.setPriority(params.getPriority());
    }
    handler.executeOnExecutor(EXECUTOR, request);
    return handler;
  }