當前位置: 首頁>>代碼示例>>Java>>正文


Java Request.execute方法代碼示例

本文整理匯總了Java中org.apache.http.client.fluent.Request.execute方法的典型用法代碼示例。如果您正苦於以下問題:Java Request.execute方法的具體用法?Java Request.execute怎麽用?Java Request.execute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.http.client.fluent.Request的用法示例。


在下文中一共展示了Request.execute方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: sendRequestToOrion

import org.apache.http.client.fluent.Request; //導入方法依賴的package包/類
/**
 * Sends a request to Orion
 *
 * @param ctxElement
 *          The context element
 * @param path
 *          the path from the context broker that determines which "operation"will be executed
 * @param responseClazz
 *          The class expected for the response
 * @return The object representing the JSON answer from Orion
 * @throws OrionConnectorException
 *           if a communication exception happens, either when contacting the context broker at
 *           the given address, or obtaining the answer from it.
 */
private <E, T> T sendRequestToOrion(E ctxElement, String path, Class<T> responseClazz) {
  String jsonEntity = gson.toJson(ctxElement);
  log.debug("Send request to Orion: {}", jsonEntity);

  Request req = Request.Post(this.orionAddr.toString() + path)
      .addHeader("Accept", APPLICATION_JSON.getMimeType())
      .bodyString(jsonEntity, APPLICATION_JSON).connectTimeout(5000).socketTimeout(5000);
  Response response;
  try {
    response = req.execute();
  } catch (IOException e) {
    throw new OrionConnectorException("Could not execute HTTP request", e);
  }

  HttpResponse httpResponse = checkResponse(response);

  T ctxResp = getOrionObjFromResponse(httpResponse, responseClazz);
  log.debug("Sent to Orion. Obtained response: {}", httpResponse);

  return ctxResp;
}
 
開發者ID:usmanullah,項目名稱:kurento-testing,代碼行數:36,代碼來源:OrionConnector.java

示例2: post

import org.apache.http.client.fluent.Request; //導入方法依賴的package包/類
private Response post(HttpRequest request) throws IOException {
    Request apacheRequest = Request.Post(request.getUrl());
    if (request.getBody() != null) {
        ContentType ct = ContentType.create(request.getContentType().getMimeType(),
                        request.getContentType().getCharset());
        apacheRequest.bodyString(request.getBody(), ct);
    } else if (request.getBodyForm() != null) {
        apacheRequest.bodyForm(buildFormBody(request.getBodyForm()));
    }
    prepareRequest(apacheRequest);
    return apacheRequest.execute();
}
 
開發者ID:DorsetProject,項目名稱:dorset-framework,代碼行數:13,代碼來源:ApacheHttpClient.java

示例3: getPage

import org.apache.http.client.fluent.Request; //導入方法依賴的package包/類
static String getPage(String targetURL) throws Exception {
    Request x = Request.Get(targetURL);
    Response y = x.execute();
    Content z = y.returnContent();
    return z.toString();
}
 
開發者ID:palette-software,項目名稱:pet-restart,代碼行數:7,代碼來源:HelperHttpClient.java

示例4: put

import org.apache.http.client.fluent.Request; //導入方法依賴的package包/類
private Response put(HttpRequest request) throws IOException {
    Request apacheRequest = Request.Put(request.getUrl());
    if (request.getBody() != null) {
        ContentType ct = ContentType.create(request.getContentType().getMimeType(),
                        request.getContentType().getCharset());
        apacheRequest.bodyString(request.getBody(), ct);
    } else if (request.getBodyForm() != null) {
        apacheRequest.bodyForm(buildFormBody(request.getBodyForm()));
    }
    prepareRequest(apacheRequest);
    return apacheRequest.execute();
}
 
開發者ID:DorsetProject,項目名稱:dorset-framework,代碼行數:13,代碼來源:ApacheHttpClient.java

示例5: get

import org.apache.http.client.fluent.Request; //導入方法依賴的package包/類
private Response get(HttpRequest request) throws IOException {
    Request apacheRequest = Request.Get(request.getUrl());
    prepareRequest(apacheRequest);
    return apacheRequest.execute();
}
 
開發者ID:DorsetProject,項目名稱:dorset-framework,代碼行數:6,代碼來源:ApacheHttpClient.java

示例6: delete

import org.apache.http.client.fluent.Request; //導入方法依賴的package包/類
private Response delete(HttpRequest request) throws IOException {
    Request apacheRequest = Request.Delete(request.getUrl());
    prepareRequest(apacheRequest);
    return apacheRequest.execute();
}
 
開發者ID:DorsetProject,項目名稱:dorset-framework,代碼行數:6,代碼來源:ApacheHttpClient.java


注:本文中的org.apache.http.client.fluent.Request.execute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。