コード例 #1
0
ファイル: HttpUtils.java プロジェクト: weimingtom/richcar
  // //////////////////////////////////////////////////////////////////////////////////////////////
  private <T> HttpHandler<T> sendRequest(
      HttpRequest request, RequestParams params, String contentType, RequestCallBack<T> callBack) {
    if (contentType != null) {
      request.setHeader("Content-Type", contentType);
    }

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

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

    handler.executeOnExecutor(executor, request);
    return handler;
  }
コード例 #2
0
ファイル: HttpUtils.java プロジェクト: weimingtom/richcar
  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, defaultResponseTextCharset, callback);

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

    handler.executeOnExecutor(executor, request, target, autoResume, autoRename);
    return handler;
  }