资源简介
HttpClient,发送异步请求,get、post请求
代码片段和文件信息
/*
* ====================================================================
* 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\.settings\org.eclipse.core.resources.prefs
文件 598 2016-07-11 11:42 http_client\.settings\org.eclipse.jdt.core.prefs
文件 2995 2016-07-11 11:51 http_client\bin\org\apache\http\examples\nio\client\AsyncClientAuthentication.class
文件 1394 2016-07-11 11:51 http_client\bin\org\apache\http\examples\nio\client\AsyncClientConfiguration$1$1.class
文件 1740 2016-07-11 11:51 http_client\bin\org\apache\http\examples\nio\client\AsyncClientConfiguration$1.class
文件 1029 2016-07-11 11:51 http_client\bin\org\apache\http\examples\nio\client\AsyncClientConfiguration$2.class
文件 11793 2016-07-11 11:51 http_client\bin\org\apache\http\examples\nio\client\AsyncClientConfiguration.class
文件 3032 2016-07-11 11:51 http_client\bin\org\apache\http\examples\nio\client\AsyncClientCustomContext.class
文件 3851 2016-07-11 11:51 http_client\bin\org\apache\http\examples\nio\client\AsyncClientCustomSSL.class
文件 2201 2016-07-11 11:51 http_client\bin\org\apache\http\examples\nio\client\AsyncClientEvictExpiredConnections$1.class
文件 1541 2016-07-11 11:51 http_client\bin\org\apache\http\examples\nio\client\AsyncClientEvictExpiredConnections$IdleConnectionEvictor.class
文件 3278 2016-07-11 11:51 http_client\bin\org\apache\http\examples\nio\client\AsyncClientEvictExpiredConnections.class
文件 2769 2016-07-11 11:51 http_client\bin\org\apache\http\examples\nio\client\AsyncClientExecuteProxy.class
文件 2065 2016-07-11 11:51 http_client\bin\org\apache\http\examples\nio\client\AsyncClientHttpExchange.class
文件 2213 2016-07-11 11:51 http_client\bin\org\apache\http\examples\nio\client\AsyncClientHttpExchangeFutureCallback$1.class
文件 2912 2016-07-11 11:51 http_client\bin\org\apache\http\examples\nio\client\AsyncClientHttpExchangeFutureCallback.class
文件 1873 2016-07-11 11:51 http_client\bin\org\apache\http\examples\nio\client\AsyncClientHttpExchangeStreaming$MyResponseConsumer.class
文件 2212 2016-07-11 11:51 http_client\bin\org\apache\http\examples\nio\client\AsyncClientHttpExchangeStreaming.class
文件 3591 2016-07-11 11:51 http_client\bin\org\apache\http\examples\nio\client\AsyncClientProxyAuthentication.class
文件 2108 2016-07-11 11:51 http_client\bin\org\apache\http\examples\nio\client\QuickStart$1.class
文件 1539 2016-07-11 11:51 http_client\bin\org\apache\http\examples\nio\client\QuickStart$2.class
文件 2108 2016-07-11 11:51 http_client\bin\org\apache\http\examples\nio\client\QuickStart$3.class
文件 3389 2016-07-11 11:51 http_client\bin\org\apache\http\examples\nio\client\QuickStart.class
文件 1765 2016-07-11 11:51 http_client\bin\org\apache\http\examples\nio\client\ZeroCopyHttpExchange$1.class
文件 2653 2016-07-11 11:51 http_client\bin\org\apache\http\examples\nio\client\ZeroCopyHttpExchange.class
文件 232771 2016-07-11 11:44 http_client\lib\commons-codec-1.6.jar
文件 279781 2016-07-11 12:32 http_client\lib\commons-httpclient-3.0.1.jar
文件 62050 2016-07-11 11:44 http_client\lib\commons-logging-1.1.3.jar
............此处省略42个文件信息
相关资源
- HttpClient实现POST GET和文件
- 使用HttpURLConnection或HttpClient方式传j
- httpclient-4.5.3.CHM
- org.apache.commons.httpclient-4.5
- org.apache.commons.httpclient资源包4.2
- 通过httpclient获取到JSON数据,展示到
- OkHttpClientManager
-
httpclient 客户端发送xm
l报文到服务器 - httpclient4.3 封装工具类
- Apache HttpClient 4.5.6
- WebApi系列-通过HttpClient来调用WebApi接口
- 统一管理系统
- 监控网页内容,发现需要的内容后弹
- httpclient请求httpsdemo
- HttpClient工具类
- HttpClient工具详细
- httpClient 调用远程接口 获取数据到本
- HttpClient4.3教程.PDF
- HttpClient发送post请求传输json数据
- org.apache.commons.httpclient
- org.apache.commons.httpclient相关架包
- httpclient以及依赖的jar包
- HttpClient.jar codec.jar logging.jar
- httpclient教程
评论
共有 条评论