HttpClient异步请求
HttpClient,发送异步请求,get、post请求
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 380 2016-07-11 11:51 http_client.classpath
文件 387 2016-07-11 11:42 http_client.project
文件 79 2016-07-11 12:12 http_client.settingsorg.eclipse.core.resources.prefs
文件 598 2016-07-11 11:42 http_client.settingsorg.eclipse.jdt.core.prefs
文件 2995 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientAsyncClientAuthentication.class
文件 1394 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientAsyncClientConfiguration$1$1.class
文件 1740 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientAsyncClientConfiguration$1.class
文件 1029 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientAsyncClientConfiguration$2.class
文件 11793 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientAsyncClientConfiguration.class
文件 3032 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientAsyncClientCustomContext.class
文件 3851 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientAsyncClientCustomSSL.class
文件 2201 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientAsyncClientEvictExpiredConnections$1.class
文件 1541 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientAsyncClientEvictExpiredConnections$IdleConnectionEvictor.class
文件 3278 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientAsyncClientEvictExpiredConnections.class
文件 2769 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientAsyncClientExecuteProxy.class
文件 2065 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientAsyncClientHttpExchange.class
文件 2213 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientAsyncClientHttpExchangeFutureCallback$1.class
文件 2912 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientAsyncClientHttpExchangeFutureCallback.class
文件 1873 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientAsyncClientHttpExchangeStreaming$MyResponseConsumer.class
文件 2212 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientAsyncClientHttpExchangeStreaming.class
文件 3591 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientAsyncClientProxyAuthentication.class
文件 2108 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientQuickStart$1.class
文件 1539 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientQuickStart$2.class
文件 2108 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientQuickStart$3.class
文件 3389 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientQuickStart.class
文件 1765 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclienteroCopyHttpExchange$1.class
文件 2653 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclienteroCopyHttpExchange.class
文件 232771 2016-07-11 11:44 http_clientlibcommons-codec-1.6.jar
文件 279781 2016-07-11 12:32 http_clientlibcommons-httpclient-3.0.1.jar
文件 62050 2016-07-11 11:44 http_clientlibcommons-logging-1.1.3.jar
............此处省略42个文件信息
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License Version 2.0 (the
* “License“); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing
* software distributed under the License is distributed on an
* “AS IS“ BASIS WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation please see
* .
*
*/
package org.apache.http.examples.nio.client;
import org.apache.http.HttpResponse;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
import org.apache.http.impl.nio.client.HttpAsyncClients;
import java.util.concurrent.Future;
/**
* A simple example that uses HttpClient to execute an HTTP request against
* a target site that requires user authentication.
*/
public class AsyncClientAuthentication {
public static void main(String[] args) throws Exception {
CredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(
new AuthScope(“localhost“ 443)
new UsernamePasswordCredentials(“username“ “password“));
CloseableHttpAsyncClient httpclient = HttpAsyncClients.custom()
.setDefaultCredentialsProvider(credsProvider)
.build();
try {
HttpGet httpget = new HttpGet(“http://localhost/“);
System.out.println(“Executing request “ + httpget.getRequestLine());
Future future = httpclient.execute(httpget null);
HttpResponse response = future.get();
System.out.println(“Response: “ + response.getStatusLine());
System.out.println(“Shutting down“);
} finally {
httpclient.close();
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 380 2016-07-11 11:51 http_client.classpath
文件 387 2016-07-11 11:42 http_client.project
文件 79 2016-07-11 12:12 http_client.settingsorg.eclipse.core.resources.prefs
文件 598 2016-07-11 11:42 http_client.settingsorg.eclipse.jdt.core.prefs
文件 2995 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientAsyncClientAuthentication.class
文件 1394 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientAsyncClientConfiguration$1$1.class
文件 1740 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientAsyncClientConfiguration$1.class
文件 1029 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientAsyncClientConfiguration$2.class
文件 11793 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientAsyncClientConfiguration.class
文件 3032 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientAsyncClientCustomContext.class
文件 3851 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientAsyncClientCustomSSL.class
文件 2201 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientAsyncClientEvictExpiredConnections$1.class
文件 1541 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientAsyncClientEvictExpiredConnections$IdleConnectionEvictor.class
文件 3278 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientAsyncClientEvictExpiredConnections.class
文件 2769 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientAsyncClientExecuteProxy.class
文件 2065 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientAsyncClientHttpExchange.class
文件 2213 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientAsyncClientHttpExchangeFutureCallback$1.class
文件 2912 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientAsyncClientHttpExchangeFutureCallback.class
文件 1873 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientAsyncClientHttpExchangeStreaming$MyResponseConsumer.class
文件 2212 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientAsyncClientHttpExchangeStreaming.class
文件 3591 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientAsyncClientProxyAuthentication.class
文件 2108 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientQuickStart$1.class
文件 1539 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientQuickStart$2.class
文件 2108 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientQuickStart$3.class
文件 3389 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclientQuickStart.class
文件 1765 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclienteroCopyHttpExchange$1.class
文件 2653 2016-07-11 11:51 http_clientinorgapachehttpexamples
ioclienteroCopyHttpExchange.class
文件 232771 2016-07-11 11:44 http_clientlibcommons-codec-1.6.jar
文件 279781 2016-07-11 12:32 http_clientlibcommons-httpclient-3.0.1.jar
文件 62050 2016-07-11 11:44 http_clientlibcommons-logging-1.1.3.jar
............此处省略42个文件信息
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)