Java 类org.apache.http.client.fluent.Content 实例源码

项目:CarmenRest-VertX    文件:TestUtility.java   
public static String post(String location, String jsonArgs)
{       
    Content result = null;

    try {
        StringEntity jsonEntity = new StringEntity(jsonArgs);
        result = Request.Post(location)
                .body(jsonEntity)
                .execute()
                .returnContent();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return (result == null) ? null : result.toString();
}
项目:CarmenRest-VertX    文件:TestUtility.java   
public static String get(String location)
{       
    Content result = null;

    try {
        result = Request.Get(location)
                .execute()
                .returnContent();
    } catch (IOException e) {
        e.printStackTrace();
    }

    System.out.println("Test Utility result = " + result.toString());

    return (result == null) ? null : result.toString();
}
项目:restvertx    文件:TestUtility.java   
public static String post(String location, String jsonArgs)
{       
    Content result = null;

    try {
        StringEntity jsonEntity = new StringEntity(jsonArgs);
        result = Request.Post(location)
                .body(jsonEntity)
                .execute()
                .returnContent();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return (result == null) ? null : result.toString();
}
项目:restvertx    文件:TestUtility.java   
public static String get(String location)
{       
    Content result = null;

    try {
        result = Request.Get(location)
                .execute()
                .returnContent();
    } catch (IOException e) {
        e.printStackTrace();
    }

    System.out.println("Test Utility result = " + result.toString());

    return (result == null) ? null : result.toString();
}
项目:pagerDutySynchronizer    文件:DefaultPagerdutyDao.java   
@Override
public Collection<PagerdutyIncident> loadUnresolvedIncidents() {
   Collection<PagerdutyIncident> pagerdutyIncidents = Lists.newArrayList();
   try {
      URI uri = new URIBuilder().setScheme("https").setHost(pagerDutyHost).setPath("/api/v1/incidents")
            .setParameter("status", "triggered,acknowledged").build();
      Content returnContent = Request.Get(uri).addHeader("Content-type", "application/json")
            .addHeader("Authorization", pagerDutyToken).execute().returnContent();
      String response = returnContent.asString();

      pagerdutyIncidents = extractIncidents(response);
   } catch (Exception e) {
      logger.error(e.getMessage(), e);
   }
   return pagerdutyIncidents;
}
项目:docker-compose-rule-spark-demo    文件:AppIT.java   
@Test
public void test() throws IOException {
  final String sparkHelloWorldServiceUrl = this.getSparkHelloWorldServiceUrl();

  final Content content = Request.Get(sparkHelloWorldServiceUrl + "/hello")
    .execute()
    .returnContent();
  Assert.assertEquals("Hello World", content.asString());
}
项目:daf-cacher    文件:HTTPClient.java   
public Token authenticate() throws IOException {
    final Gson gson = new GsonBuilder().create();
    final Content response = Request.Post(this.metabaseHost.toString() + "/session")
            .setHeader("Content-Type", "application/json")
            .body(new StringEntity(gson.toJson(this.credential)))
            .execute().returnContent();

    this.token = gson.fromJson(response.asString(), Token.class);
    this.authenticated = true;
    return this.token;
}
项目:LDN4IIIF    文件:FetchRequest.java   
public void setResponse(CloseableHttpResponse response) throws UnsupportedOperationException, IOException {
    this.response = response;
    if(response.getEntity()!=null) {
        byte[] byteArray = IOUtils.toByteArray(response.getEntity().getContent());
        ContentType contentType = ContentType.get(response.getEntity());
        response.close();
        this.content=new Content(byteArray, contentType);
    }
}
项目:LDN4IIIF    文件:FetchRequest.java   
public Content getContent() throws IOException {
//      byte[] byteArray = IOUtils.toByteArray(response.getEntity().getContent());
//      ContentType contentType = ContentType.get(response.getEntity());
//      response.close();
//      return new Content(byteArray, contentType);
        return content;
    }
项目:bootique-undertow-demo    文件:EchoRestControllerIT.java   
@Test
public void handleGetRequest() throws Exception {
    final Content content = Request.Get("http://localhost:8080/")
            .execute()
            .returnContent();

    assertEquals("Hello World!", content.asString());
}
项目:bootique-undertow-demo    文件:EchoRestControllerIT.java   
@Test
public void handlePostRequest() throws Exception {
    final Content content = Request.Post("http://localhost:8080/Vader")
            .execute()
            .returnContent();

    assertEquals("Hello Vader!", content.asString());
}
项目:bootique-undertow-demo    文件:EchoRestControllerIT.java   
@Test
public void handleStatic() throws Exception {
    final Content content = Request.Get("http://localhost:8080/static/test.txt")
            .execute()
            .returnContent();

    assertEquals("Content", content.asString());
}
项目:bootique-undertow-demo    文件:EchoRestControllerIT.java   
@Test
public void handleException() throws Exception {
    final Content content = Request.Get("http://localhost:8080/exception")
            .execute()
            .returnContent();

    assertEquals("Programmatic Error", content.asString());
}
项目:historybook-import    文件:Crawler.java   
/**
 * Fetch the body for a given HistoryRecord and add it to the record
 * 
 * @param record HistoryRecord containing a URL to fetch
 * @return
 */
protected static HistoryRecord fetchBody(HistoryRecord record) {
    try {
        Content content = 
                Request.Get(encodeSpecialChars(record.getUrl()))
                    .execute()
                    .returnContent();
        if (content != null) {
            record.setBody(content.asString(Charsets.UTF_8));
        }
    } catch (IOException e) {
        System.err.println("Failed to fetch " + record.getUrl() + ": " + e.getLocalizedMessage());
    }
    return record;
}
项目:CarmenRest-VertX    文件:TestUtility.java   
public static String post(String location)
{       
    Content result = null;

    try {
        result = Request.Post(location)
                .execute()
                .returnContent();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return (result == null) ? null : result.toString();
}
项目:restvertx    文件:TestUtility.java   
public static String post(String location)
{       
    Content result = null;

    try {
        result = Request.Post(location)
                .execute()
                .returnContent();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return (result == null) ? null : result.toString();
}
项目:liferay-node-poller    文件:NodePollerSender.java   
public static void send() throws URISyntaxException {
        URIBuilder builder = new URIBuilder(_nodePollerURL);
        JSONObject receiveJSON = JSONFactoryUtil.createJSONObject();
        int i = 0;
        for(RequestParams params: _requestParams){
            JSONObject object = JSONFactoryUtil.createJSONObject();
            object.put("portletId", params.getPortletId()).put("data", params.getData().toString())
            .put("userIds", String.valueOf(params.getUserId()));
//              builder.addParameter("portletId", params.getPortletId()).addParameter("data", params.getData().toString()).
//              addParameter("userIds", String.valueOf(params.getUserId()));
            receiveJSON.put(i+"", object);      
            i++;
        }
        _requestParams.clear();
        builder.addParameter("receive", receiveJSON.toString());

        final Request request = Request.Get(builder.build());

        Future<Content> future = async.execute(request, new FutureCallback<Content>() {
            public void failed (final Exception e) {
                _log.error(e.getMessage() +": "+ request);
                PollerProcessorUtil.destroy();
            }
            public void completed (final Content content) {
                _log.info("Request completed: "+ request);
//              _log.info("Response: "+ content.asString());
            }

            public void cancelled () {}
        });

    }
项目:jsif    文件:SelfInitializingFakeE2E.java   
private String doHttpCall(int port) throws IOException {
    Content content = Request.Get(baseUrl + ":" + port + httpPath)
            .execute().returnContent();
    return content.asString();
}
项目:daf-cacher    文件:HTTPClient.java   
public List<Card> getPublicCards() throws IOException {
    final Content content = executeGetAuthenticatedMethod("/card/public");
    final Gson gson = new GsonBuilder().create();
    return gson.fromJson(content.asString(), new TypeToken<List<Card>>() {
    }.getType());
}
项目:daf-cacher    文件:HTTPClient.java   
private Content executeGetAuthenticatedMethod(final String apiEndpoint) throws IOException {
    return Request.Get(this.metabaseHost.toString() + apiEndpoint)
            .setHeader("Content-Type", "application/json")
            .setHeader(HEADER_X_KEY, this.token.getId())
            .execute().returnContent();
}
项目:pet-restart    文件:HelperHttpClient.java   
static String getPage(String targetURL) throws Exception {
    Request x = Request.Get(targetURL);
    Response y = x.execute();
    Content z = y.returnContent();
    return z.toString();
}