Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
58 lines (45 loc) · 1.93 KB

File metadata and controls

58 lines (45 loc) · 1.93 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
public class HTTPClientTest {
public static void main(String[] argv) throws IOException {
System.out.println("Start");
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
cm.setMaxTotal(200);
cm.setDefaultMaxPerRoute(20);
HttpHost google = new HttpHost("http://www.google.com/", 80);
cm.setMaxPerRoute(new HttpRoute(google), 50);
//CloseableHttpClient httpclient = HttpClients.createDefault();
CloseableHttpClient httpclient = HttpClients.custom()
.setConnectionManager(cm)
.build();
HttpClientContext context = HttpClientContext.create();
HttpGet httpget = new HttpGet("http://www.google.com/");
CloseableHttpResponse response = httpclient.execute(httpget,context);
try {
HttpHost target = context.getTargetHost();
System.out.println("HttpHost " + target);
HttpEntity entity = response.getEntity();
if (entity != null) {
long len = entity.getContentLength();
//if (len != -1 && len < 2048) {
System.out.println(EntityUtils.toString(entity));
//} else {
// Stream content out
//}
}
} finally {
response.close();
}
httpclient.close();
System.out.println("End");
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.