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


Java HttpAsyncClient类代码示例

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


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

示例1: createAsyncRequest

import org.apache.http.nio.client.HttpAsyncClient; //导入依赖的package包/类
@Override
public AsyncClientHttpRequest createAsyncRequest(URI uri, HttpMethod httpMethod) throws IOException {
	HttpAsyncClient asyncClient = getHttpAsyncClient();
	startAsyncClient();
	HttpUriRequest httpRequest = createHttpUriRequest(httpMethod, uri);
	postProcessHttpRequest(httpRequest);
       HttpContext context = createHttpContext(httpMethod, uri);
       if (context == null) {
           context = HttpClientContext.create();
       }
	// Request configuration not set in the context
	if (context.getAttribute(HttpClientContext.REQUEST_CONFIG) == null) {
		// Use request configuration given by the user, when available
		RequestConfig config = null;
		if (httpRequest instanceof Configurable) {
			config = ((Configurable) httpRequest).getConfig();
		}
		if (config == null) {
			config = createRequestConfig(asyncClient);
		}
		if (config != null) {
			context.setAttribute(HttpClientContext.REQUEST_CONFIG, config);
		}
	}
	return new HttpComponentsAsyncClientHttpRequest(asyncClient, httpRequest, context);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:27,代码来源:HttpComponentsAsyncClientHttpRequestFactory.java

示例2: AbstractRemoteOperationInvocation

import org.apache.http.nio.client.HttpAsyncClient; //导入依赖的package包/类
protected AbstractRemoteOperationInvocation(
    final @NotNull HttpHost host,
    final @NotNull HttpAsyncClient httpClient,
    final @NotNull String resourceName,
    final @NotNull OD operationDeclaration,
    final @NotNull ServerProtocol serverProtocol,
    final @NotNull Charset charset,
    final int okStatusCode) {

  this.host = host;
  this.httpClient = httpClient;
  this.resourceName = resourceName;
  this.operationDeclaration = operationDeclaration;
  this.serverProtocol = serverProtocol;
  this.charset = charset;
  this.okStatusCode = okStatusCode;
}
 
开发者ID:SumoLogic,项目名称:epigraph,代码行数:18,代码来源:AbstractRemoteOperationInvocation.java

示例3: RemoteCustomOperationInvocation

import org.apache.http.nio.client.HttpAsyncClient; //导入依赖的package包/类
public RemoteCustomOperationInvocation(
    final @NotNull HttpHost host,
    final @NotNull HttpAsyncClient httpClient,
    final @NotNull String resourceName,
    final @NotNull CustomOperationDeclaration operationDeclaration,
    final @NotNull ServerProtocol serverProtocol,
    final @NotNull Charset charset) {
  super(host, httpClient, resourceName, operationDeclaration, serverProtocol, charset, HttpStatusCode.OK);
}
 
开发者ID:SumoLogic,项目名称:epigraph,代码行数:10,代码来源:RemoteCustomOperationInvocation.java

示例4: RemoteReadOperationInvocation

import org.apache.http.nio.client.HttpAsyncClient; //导入依赖的package包/类
public RemoteReadOperationInvocation(
    final @NotNull HttpHost host,
    final @NotNull HttpAsyncClient httpClient,
    final @NotNull String resourceName,
    final @NotNull ReadOperationDeclaration operationDeclaration,
    final @NotNull ServerProtocol serverProtocol,
    final @NotNull Charset charset) {

  super(host, httpClient, resourceName, operationDeclaration, serverProtocol, charset, HttpStatusCode.OK);
}
 
开发者ID:SumoLogic,项目名称:epigraph,代码行数:11,代码来源:RemoteReadOperationInvocation.java

示例5: RemoteUpdateOperationInvocation

import org.apache.http.nio.client.HttpAsyncClient; //导入依赖的package包/类
public RemoteUpdateOperationInvocation(
    final @NotNull HttpHost host,
    final @NotNull HttpAsyncClient httpClient,
    final @NotNull String resourceName,
    final @NotNull UpdateOperationDeclaration operationDeclaration,
    final @NotNull ServerProtocol serverProtocol,
    final @NotNull Charset charset) {
  super(host, httpClient, resourceName, operationDeclaration, serverProtocol, charset, HttpStatusCode.OK);
}
 
开发者ID:SumoLogic,项目名称:epigraph,代码行数:10,代码来源:RemoteUpdateOperationInvocation.java

示例6: RemoteDeleteOperationInvocation

import org.apache.http.nio.client.HttpAsyncClient; //导入依赖的package包/类
public RemoteDeleteOperationInvocation(
    final @NotNull HttpHost host,
    final @NotNull HttpAsyncClient httpClient,
    final @NotNull String resourceName,
    final @NotNull DeleteOperationDeclaration operationDeclaration,
    final @NotNull ServerProtocol serverProtocol,
    final @NotNull Charset charset) {

  super(host, httpClient, resourceName, operationDeclaration, serverProtocol, charset, HttpStatusCode.OK);
}
 
开发者ID:SumoLogic,项目名称:epigraph,代码行数:11,代码来源:RemoteDeleteOperationInvocation.java

示例7: RemoteCreateOperationInvocation

import org.apache.http.nio.client.HttpAsyncClient; //导入依赖的package包/类
public RemoteCreateOperationInvocation(
    final @NotNull HttpHost host,
    final @NotNull HttpAsyncClient httpClient,
    final @NotNull String resourceName,
    final @NotNull CreateOperationDeclaration operationDeclaration,
    final @NotNull ServerProtocol serverProtocol,
    final @NotNull Charset charset) {
  super(host, httpClient, resourceName, operationDeclaration, serverProtocol, charset, HttpStatusCode.CREATED);
}
 
开发者ID:SumoLogic,项目名称:epigraph,代码行数:10,代码来源:RemoteCreateOperationInvocation.java

示例8: run

import org.apache.http.nio.client.HttpAsyncClient; //导入依赖的package包/类
@Override
public void run() {
    // To change body of implemented methods use File | Settings | File Templates.if (log.isDebugEnabled())
    log.debug("URI=[{}] 의 웹 컨텐츠를 비동기 방식으로 다운로드 받아 캐시합니다.", url);

    try {

        String responseStr;
        HttpAsyncClient httpClient = new DefaultHttpAsyncClient();
        httpClient.start();
        HttpGet request = new HttpGet(url);
        Future<HttpResponse> future = httpClient.execute(request, null);

        HttpResponse response = future.get();
        responseStr = EntityUtils.toString(response.getEntity(), Charsets.UTF_8.toString());
        httpClient.shutdown();

        if (log.isDebugEnabled())
            log.debug("URI=[{}]로부터 웹 컨텐츠를 다운로드 받았습니다. responseStr=[{}]",
                      url, StringTool.ellipsisChar(responseStr, 255));

        ctx.getResponse().setCharacterEncoding("UTF-8");
        PrintWriter writer = ctx.getResponse().getWriter();
        writer.write(responseStr);
        writer.close();
        ctx.complete();
    } catch (Exception ignored) {
        throw new RuntimeException(ignored);
    }
}
 
开发者ID:debop,项目名称:debop4j,代码行数:31,代码来源:AsyncLoadPage.java

示例9: HttpComponentsAsyncClientHttpRequest

import org.apache.http.nio.client.HttpAsyncClient; //导入依赖的package包/类
HttpComponentsAsyncClientHttpRequest(HttpAsyncClient httpClient, HttpUriRequest httpRequest, HttpContext httpContext) {
	this.httpClient = httpClient;
	this.httpRequest = httpRequest;
	this.httpContext = httpContext;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:6,代码来源:HttpComponentsAsyncClientHttpRequest.java

示例10: createAsyncRequest

import org.apache.http.nio.client.HttpAsyncClient; //导入依赖的package包/类
@Override
public AsyncClientHttpRequest createAsyncRequest(URI uri, HttpMethod httpMethod) throws IOException {
	HttpAsyncClient asyncClient = getHttpAsyncClient();
	startAsyncClient();
	HttpUriRequest httpRequest = createHttpUriRequest(httpMethod, uri);
	postProcessHttpRequest(httpRequest);
       HttpContext context = createHttpContext(httpMethod, uri);
       if (context == null) {
           context = HttpClientContext.create();
       }
       // Request configuration not set in the context
       if (context.getAttribute(HttpClientContext.REQUEST_CONFIG) == null) {
           // Use request configuration given by the user, when available
           RequestConfig config = null;
           if (httpRequest instanceof Configurable) {
               config = ((Configurable) httpRequest).getConfig();
           }
           if (config == null) {
               config = RequestConfig.DEFAULT;
           }
           context.setAttribute(HttpClientContext.REQUEST_CONFIG, config);
       }
	return new HttpComponentsAsyncClientHttpRequest(asyncClient, httpRequest, context);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:HttpComponentsAsyncClientHttpRequestFactory.java

示例11: getProxyClientAsync

import org.apache.http.nio.client.HttpAsyncClient; //导入依赖的package包/类
protected HttpAsyncClient getProxyClientAsync() {
    return httpClient;
}
 
开发者ID:bluecreator,项目名称:http-agent,代码行数:4,代码来源:AgentServlet.java

示例12: DefaultClient

import org.apache.http.nio.client.HttpAsyncClient; //导入依赖的package包/类
public DefaultClient(HttpAsyncClient client, ClientConfig config) {
    this.client = client;
    this.config = config;
}
 
开发者ID:CloudBans,项目名称:java-api-client,代码行数:5,代码来源:DefaultClient.java

示例13: getClient

import org.apache.http.nio.client.HttpAsyncClient; //导入依赖的package包/类
public HttpAsyncClient getClient() {
    return client;
}
 
开发者ID:CloudBans,项目名称:java-api-client,代码行数:4,代码来源:DefaultClient.java

示例14: http

import org.apache.http.nio.client.HttpAsyncClient; //导入依赖的package包/类
public HttpAsyncClient http() {
    return clnt;
}
 
开发者ID:yunpian,项目名称:yunpian-java-sdk,代码行数:4,代码来源:YunpianClient.java

示例15: AbstractClient

import org.apache.http.nio.client.HttpAsyncClient; //导入依赖的package包/类
public AbstractClient(String baseUri, HttpAsyncClient httpClient) throws URISyntaxException {
    this(new URI(baseUri), httpClient);
}
 
开发者ID:kafka101,项目名称:clickstream-rest-proxy,代码行数:4,代码来源:AbstractClient.java


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