Ejemplo n.º 1
0
  /**
   * For http get, only 200 is normal status, so don't need return other extra infomation.
   *
   * @param url
   * @param params
   * @return response content
   * @throws IOException any network exception happen
   */
  public HttpStatus doGet(String url, Map<String, String> params) throws IOException {

    String requestUrl = UrlUtils.expandUrl(url, params);
    logger.debug(" get url :" + requestUrl);
    HttpGet method = new HttpGet(requestUrl);
    return commit(method);
  };
Ejemplo n.º 2
0
  /**
   * Do a general post request with a HttpEntity object.
   *
   * @param url
   * @param headers
   * @param params
   * @param entity
   * @return
   * @throws IOException any network exception happen
   */
  public HttpStatus doPost(
      String url, Map<String, String> headers, Map<String, String> params, HttpEntity entity)
      throws IOException {
    HttpPost method = new HttpPost(UrlUtils.expandUrl(url, params));

    if (headers != null) {
      for (Map.Entry<String, String> entry : headers.entrySet()) {
        method.addHeader(entry.getKey(), entry.getValue());
      }
    }
    method.setEntity(entity);
    return commit(method);
  }
Ejemplo n.º 3
0
 /**
  * Run a http delete operation
  *
  * @param url
  * @param params
  * @return
  * @throws IOException any network exception happen
  */
 public HttpStatus doDelete(String url, Map<String, String> params) throws IOException {
   HttpDelete method = new HttpDelete(UrlUtils.expandUrl(url, params));
   return commit(method);
 };
Ejemplo n.º 4
0
 /**
  * run a general put requeest with a string
  *
  * @param url
  * @param params
  * @param body
  * @return
  * @throws IOException any network exception happen
  */
 public HttpStatus doPut(String url, Map<String, String> params, StringEntity body)
     throws IOException {
   HttpPut method = new HttpPut(UrlUtils.expandUrl(url, params));
   method.setEntity(body);
   return commit(method);
 }