当前位置: 首页>>代码示例>>Java>>正文


Java Content类代码示例

本文整理汇总了Java中org.apache.http.client.fluent.Content的典型用法代码示例。如果您正苦于以下问题:Java Content类的具体用法?Java Content怎么用?Java Content使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Content类属于org.apache.http.client.fluent包,在下文中一共展示了Content类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: authenticate

import org.apache.http.client.fluent.Content; //导入依赖的package包/类
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;
}
 
开发者ID:italia,项目名称:daf-cacher,代码行数:12,代码来源:HTTPClient.java

示例2: post

import org.apache.http.client.fluent.Content; //导入依赖的package包/类
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();
}
 
开发者ID:SalimCastellanos,项目名称:CarmenRest-VertX,代码行数:17,代码来源:TestUtility.java

示例3: get

import org.apache.http.client.fluent.Content; //导入依赖的package包/类
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();
}
 
开发者ID:SalimCastellanos,项目名称:CarmenRest-VertX,代码行数:17,代码来源:TestUtility.java

示例4: loadUnresolvedIncidents

import org.apache.http.client.fluent.Content; //导入依赖的package包/类
@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;
}
 
开发者ID:shopping24,项目名称:pagerDutySynchronizer,代码行数:17,代码来源:DefaultPagerdutyDao.java

示例5: test

import org.apache.http.client.fluent.Content; //导入依赖的package包/类
@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());
}
 
开发者ID:SchulteMarkus,项目名称:docker-compose-rule-spark-demo,代码行数:10,代码来源:AppIT.java

示例6: getContent

import org.apache.http.client.fluent.Content; //导入依赖的package包/类
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;
	}
 
开发者ID:nfreire,项目名称:LDN4IIIF,代码行数:8,代码来源:FetchRequest.java

示例7: handleGetRequest

import org.apache.http.client.fluent.Content; //导入依赖的package包/类
@Test
public void handleGetRequest() throws Exception {
    final Content content = Request.Get("http://localhost:8080/")
            .execute()
            .returnContent();

    assertEquals("Hello World!", content.asString());
}
 
开发者ID:bootique-examples,项目名称:bootique-undertow-demo,代码行数:9,代码来源:EchoRestControllerIT.java

示例8: handlePostRequest

import org.apache.http.client.fluent.Content; //导入依赖的package包/类
@Test
public void handlePostRequest() throws Exception {
    final Content content = Request.Post("http://localhost:8080/Vader")
            .execute()
            .returnContent();

    assertEquals("Hello Vader!", content.asString());
}
 
开发者ID:bootique-examples,项目名称:bootique-undertow-demo,代码行数:9,代码来源:EchoRestControllerIT.java

示例9: handleStatic

import org.apache.http.client.fluent.Content; //导入依赖的package包/类
@Test
public void handleStatic() throws Exception {
    final Content content = Request.Get("http://localhost:8080/static/test.txt")
            .execute()
            .returnContent();

    assertEquals("Content", content.asString());
}
 
开发者ID:bootique-examples,项目名称:bootique-undertow-demo,代码行数:9,代码来源:EchoRestControllerIT.java

示例10: handleException

import org.apache.http.client.fluent.Content; //导入依赖的package包/类
@Test
public void handleException() throws Exception {
    final Content content = Request.Get("http://localhost:8080/exception")
            .execute()
            .returnContent();

    assertEquals("Programmatic Error", content.asString());
}
 
开发者ID:bootique-examples,项目名称:bootique-undertow-demo,代码行数:9,代码来源:EchoRestControllerIT.java

示例11: fetchBody

import org.apache.http.client.fluent.Content; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:abuchanan920,项目名称:historybook-import,代码行数:21,代码来源:Crawler.java

示例12: send

import org.apache.http.client.fluent.Content; //导入依赖的package包/类
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 () {}
		});
		
	}
 
开发者ID:saggiyogesh,项目名称:liferay-node-poller,代码行数:33,代码来源:NodePollerSender.java

示例13: doHttpCall

import org.apache.http.client.fluent.Content; //导入依赖的package包/类
private String doHttpCall(int port) throws IOException {
    Content content = Request.Get(baseUrl + ":" + port + httpPath)
            .execute().returnContent();
    return content.asString();
}
 
开发者ID:maximn,项目名称:jsif,代码行数:6,代码来源:SelfInitializingFakeE2E.java

示例14: getPublicCards

import org.apache.http.client.fluent.Content; //导入依赖的package包/类
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());
}
 
开发者ID:italia,项目名称:daf-cacher,代码行数:7,代码来源:HTTPClient.java

示例15: executeGetAuthenticatedMethod

import org.apache.http.client.fluent.Content; //导入依赖的package包/类
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();
}
 
开发者ID:italia,项目名称:daf-cacher,代码行数:7,代码来源:HTTPClient.java


注:本文中的org.apache.http.client.fluent.Content类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。