Example #1
0
 @Override
 public Object clone() throws CloneNotSupportedException {
   HttpRequest clone = (HttpRequest) super.clone();
   if (this.entity != null) {
     clone.entity = (HttpEntity) CloneUtils.clone(this.entity);
   }
   return clone;
 }
Example #2
0
  // //////////////////////////////////////////////////////////////////////////////////////////////
  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;
  }
Example #3
0
  private ResponseStream sendSyncRequest(
      HttpRequest request, RequestParams params, String contentType) throws HttpException {
    if (contentType != null) {
      request.setHeader("Content-Type", contentType);
    }

    SyncHttpHandler handler =
        new SyncHttpHandler(httpClient, httpContext, defaultResponseTextCharset);

    handler.setExpiry(currentRequestExpiry);
    handler.setHttpRedirectHandler(httpRedirectHandler);
    request.setRequestParams(params);
    try {
      return handler.sendRequest(request);
    } catch (com.fortune.util.HttpException e) {
      e.printStackTrace();
    }
    return null;
  }
Example #4
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, defaultResponseTextCharset, callback);

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

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