在Apache HttpClient中设置套接字缓冲区大小 [英] Setting socket buffer size in Apache HttpClient
本文介绍了在Apache HttpClient中设置套接字缓冲区大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Apache HttpClient版本4.3.3中设置套接字缓冲区大小?
How do you set the socket buffer size in Apache HttpClient version 4.3.3?
推荐答案
HttpClient client = new DefaultHttpClient();
client.getParams().setParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 128 * 1024);
HttpPost post = new HttpPost(url);
String res = null;
try
{
post.addHeader("Connection", "Keep-Alive");
post.addHeader("Content-Name", selectedFile.getName());
post.setEntity(new ByteArrayEntity(fileBytes));
HttpResponse response = client.execute(post);
res = EntityUtils.toString(response.getEntity());
}
catch (Exception e)
{
e.printStackTrace();
}
这篇关于在Apache HttpClient中设置套接字缓冲区大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文