- 浏览: 273421 次
- 性别:
- 来自: 深圳
文章分类
最新评论
-
tan_1208815066:
传送pdf 的文件 不能正确的 传送
试试用Socket传文件 -
richardri:
结果是0怎么解决?支持mov、mp4、3gp吗?
JAVA獲取視頻文件的播放長度 -
zhujia130:
xiaoyaodandan 写道结果是0.。。。。。你给的路径 ...
JAVA獲取視頻文件的播放長度 -
xiaoyaodandan:
结果是0.。。。。。
JAVA獲取視頻文件的播放長度 -
flowerjacky:
明了
Java事务处理类
Components
An example that executes HTTP requests from multiple worker threads.
线程请求执行
一个多线程程执行HTTP请求的例子。
package cn.lake.util; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.HttpVersion; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.conn.ClientConnectionManager; import org.apache.http.conn.params.ConnManagerParams; import org.apache.http.conn.scheme.PlainSocketFactory; import org.apache.http.conn.scheme.Scheme; import org.apache.http.conn.scheme.SchemeRegistry; import org.apache.http.conn.ssl.SSLSocketFactory; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager; import org.apache.http.params.BasicHttpParams; import org.apache.http.params.HttpParams; import org.apache.http.params.HttpProtocolParams; import org.apache.http.protocol.HttpContext; import org.apache.http.protocol.BasicHttpContext; import org.apache.http.util.EntityUtils; /** * An example that performs GETs from multiple threads. * * @author Michael Becke */ public class ClientMultiThreadedExecution { public static void main(String[] args) throws Exception { // Create and initialize HTTP parameters HttpParams params = new BasicHttpParams(); ConnManagerParams.setMaxTotalConnections(params, 100); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); // Create and initialize scheme registry SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); schemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443)); // Create an HttpClient with the ThreadSafeClientConnManager. // This connection manager must be used if more than one thread will // be using the HttpClient. ClientConnectionManager cm = new ThreadSafeClientConnManager(params, schemeRegistry); HttpClient httpClient = new DefaultHttpClient(cm, params); // create an array of URIs to perform GETs on String[] urisToGet = { "http://jakarta.apache.org/", "http://jakarta.apache.org/commons/", "http://jakarta.apache.org/commons/httpclient/", "http://svn.apache.org/viewvc/jakarta/httpcomponents/" }; // create a thread for each URI GetThread[] threads = new GetThread[urisToGet.length]; for (int i = 0; i < threads.length; i++) { HttpGet httpget = new HttpGet(urisToGet[i]); threads[i] = new GetThread(httpClient, httpget, i + 1); } // start the threads for (int j = 0; j < threads.length; j++) { threads[j].start(); } } /** * A thread that performs a GET. */ static class GetThread extends Thread { private final HttpClient httpClient; private final HttpContext context; private final HttpGet httpget; private final int id; public GetThread(HttpClient httpClient, HttpGet httpget, int id) { this.httpClient = httpClient; this.context = new BasicHttpContext(); this.httpget = httpget; this.id = id; } /** * Executes the GetMethod and prints some status information. */ @Override public void run() { System.out.println(id + " - about to get something from " + httpget.getURI()); try { // execute the method HttpResponse response = httpClient.execute(httpget, context); System.out.println(id + " - get executed"); // get the response body as an array of bytes HttpEntity entity = response.getEntity(); if (entity != null) { byte[] bytes = EntityUtils.toByteArray(entity); System.out.println(id + " - " + bytes.length + " bytes read"); } } catch (Exception e) { httpget.abort(); System.out.println(id + " - error: " + e); } } } }
翻譯的不好,請見諒!
评论
5 楼
karidyang
2009-02-01
因为这是中文~~~~
4 楼
gembler
2009-01-15
给个理由为什么不去看官方文档而看你的贴子
3 楼
struts
2009-01-15
你发的这些东西有什么用?怎么用?
2 楼
Jatula
2009-01-15
dhxlsfn 写道
建议楼主发的"HttpClient Examples:..."系列放到“入门讨论区”去。 原因如下: 1) 开贴多,每贴有效内容少 2) 没什么原创,基本上是拷贝Apache HttpClient的原文和例子,每贴翻译一句话。相信真需要使用HttpClient的人,会去官方网站看文档,而不是来这里。 这样的帖子太多会造成Java版面质量下降,首页几乎全是这系列帖子了,原创都给挤没了。 感觉楼主在疯狂刷分,呵呵。
不好意思,不过我只把这里当存一些有点用的地方了,具体说刷分吗,分数我倒不看重,楼主要扣就扣吧;顺便问一句,怎么才能发了之后不会挤掉别人的文章,因为影响质量也不好;
1 楼
dhxlsfn
2009-01-15
建议楼主发的"HttpClient Examples:..."系列放到“入门讨论区”去。
原因如下:
1) 开贴多,每贴有效内容少
2) 没什么原创,基本上是拷贝Apache HttpClient的原文和例子,每贴翻译一句话。相信真需要使用HttpClient的人,会去官方网站看文档,而不是来这里。
这样的帖子太多会造成Java版面质量下降,首页几乎全是这系列帖子了,原创都给挤没了。
感觉楼主在疯狂刷分,呵呵。
原因如下:
1) 开贴多,每贴有效内容少
2) 没什么原创,基本上是拷贝Apache HttpClient的原文和例子,每贴翻译一句话。相信真需要使用HttpClient的人,会去官方网站看文档,而不是来这里。
这样的帖子太多会造成Java版面质量下降,首页几乎全是这系列帖子了,原创都给挤没了。
感觉楼主在疯狂刷分,呵呵。
发表评论
-
junit实现测试类(在Spring2.5中)
2009-01-17 15:14 2372第一步: 创建JAVA项目,也可以是Web项目,加入Sprin ... -
HttpClient Examples:Custom protocol interceptors
2009-01-15 14:06 1479官方主頁:http://hc.apache.org/ Co ... -
HttpClient Examples:Custom SSL context
2009-01-15 13:58 2005官方主頁:http://hc.apache.org/ Co ... -
HttpClient Examples:Form based logon
2009-01-15 13:49 1978官方主頁:http://hc.apache.org/ Co ... -
HttpClient Examples:Custom execution context
2009-01-15 13:46 1524官方主頁:http://hc.apache.org/ Co ... -
HttpClient Examples:Chunk encoded POST
2009-01-15 12:36 2149官方主頁:http://hc.apache.org/ Co ... -
HttpClient Examples:Proxy authentication
2009-01-15 12:26 1347官方主頁:http://hc.apache.org/ Co ... -
HttpClient Examples:Request via a proxy
2009-01-15 12:19 2178官方主頁:http://hc.apache.org/ Co ... -
HttpClient Examples:Abort method
2009-01-15 12:06 1567官方主頁:http://hc.apache.org/ Co ... -
HttpClient Examples:Manual connection release
2009-01-15 11:54 1153官方主頁:http://hc.apache.org/ Co ... -
HttpClient Examples:Response handling
2009-01-15 11:44 2276官方主頁:http://hc.apache.org/ Co ... -
使用commons-codec包加密字符串(MD5,SHA1,BASE64)
2009-01-13 13:56 8181commons-codec包可以从apache下载,最新版是1 ... -
Java对称加密编码:BESA64
2009-01-13 10:58 2459package cn.lake.util; import s ... -
Java对称加密编码:IDEA
2009-01-13 10:55 2088package cn.lake.util; /** * J ... -
用java获得你电脑中的cpu数量
2009-01-13 10:41 2329System.out.println("你的电脑cp ... -
JAVA的国际化问题讨论
2008-12-18 15:05 1040一切有一个问题相当苦脑:JAVA的国际化问题; 如 ... -
客户请求的浏览器类型
2008-12-17 00:17 885<td width="50%"> ... -
同时启动多个resion
2008-12-09 15:55 993在本地同时启动多个Resin,要修改2个文件,总共是3个处 一 ... -
JSP基本语法加实例
2008-12-09 13:38 1586应作者要求:【转】http://www.cnblogs.com ... -
struts标签logic
2008-12-08 16:32 1515<!--######################## ...
相关推荐
JAVAHttpClientThe server failed to respond with a validCaused by: org.apache.htt
Maven坐标:org.apache.httpcomponents:httpclient:4.5.13; 标签:apache、httpcomponents、httpclient、jar包、java、中文文档; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档...
import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.httpclient.methods....
赠送jar包:httpclient-4.5.5.jar; 赠送原API文档:httpclient-4.5.5-javadoc.jar; 赠送源代码:httpclient-4.5.5-sources.jar; 包含翻译后的API文档:httpclient-4.5.5-javadoc-API文档-中文(简体)版.zip ...
只是jar包
ribbon-httpclient-2.2.5.jar
wechatpay-apache-httpclient 概览 的扩展,实现了请求签名的生成和应答签名的验证。...implementation 'com.github.wechatpay-apiv3:wechatpay-apache-httpclient:0.2.2' Maven 加入以下依赖 <groupId>com.github.w
commons-httpclient-3.1jar包,有需要的请下载 本资料共包含以下附件: commons-httpclient-3.1jar包.rar
Request是对httpclient的封装,类似于python的request库,用法Request.Get(pictureUrl).execute().returnContent().toString();需要以来httpclient和httpcore包。2020年1月更新。
下面给大家展示了AndroidHttpClient结构: public final class AndroidHttpClient extends Object implements HttpClient 前言: 这类其实是Google对阿帕奇的HttpClient的一个封装,一些默认属性有android做了一些...
码头ReactiveStream HttpClient 围绕的包装器。...// Create a request using the HttpClient APIs.Request request = httpClient . newRequest( " http://localhost:8080/path " );// Wrap the request using the
Maven坐标:org.apache.httpcomponents:httpclient:4.5.6; 标签:apache、httpcomponents、httpclient、jar包、java、中文文档; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档...
Maven坐标:org.apache.httpcomponents:httpclient:4.5.13; 标签:apache、httpcomponents、httpclient、jar包、java、中英对照文档; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览...
基于c++11 httpclient https://github.com/iEternity/HttpClient github上是基于win的,附件为linux平台,以及android源码环境生成的主机host bin程序,在android 8.1,linux14.04环境均编译通过 内含CMakelists ...
httpclient-4.3.1.jar httpcore-4.4.13.jar commons-logging-1.2.jar
Maven坐标:org.apache.httpcomponents:httpclient:4.5.10; 标签:apache、httpcomponents、httpclient、中文文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档...
HttpClientUtil 一个Http请求使用HttpClient访问服务器,我们也可以将文件上传到服务器,例如文件或图片。它提供了在您的上传过程中更新进度的接口。
Maven坐标:org.apache.httpcomponents:httpclient:4.2.5; 标签:apache、httpcomponents、httpclient、中文文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档...
commons-httpclient-3.0.jar JAVA中使用HttpClient可以用到
分享给大家供大家参考,具体如下: 微信小程序里自己封装了请求的函数,但几乎每个...httpClient:{ request:function(method,url,data){ //返回一个promise实例 return new Promise( (resolve,reject)=>{ wx.requ