httpexec.setParams(params);
Scheme http = (Scheme) beanfactory.getBean("http-scheme");
HttpHost host = new HttpHost("www.yahoo.com", 80, http);
HttpRequestFactory requestfactory = (HttpRequestFactory) beanfactory.getBean("http-request-factory");
HttpClientConnection conn = (HttpClientConnection) beanfactory.getBean("http-connection");
ConnectionReuseStrategy connStrategy = (ConnectionReuseStrategy) beanfactory.getBean("conn-reuse-strategy");
conn.setTargetHost(host);
try {
HttpRequest request1 = requestfactory.newHttpRequest("GET", "/");
HttpResponse response1 = httpexec.execute(request1, conn);
System.out.println("<< Response: " + response1.getStatusLine());
System.out.println(EntityUtils.toString(response1.getEntity()));
System.out.println("==============");
if (connStrategy.keepAlive(response1)) {
System.out.println("Connection kept alive...");
} else {
conn.close();
System.out.println("Connection closed...");
}
HttpRequest request2 = requestfactory.newHttpRequest("GET", "/stuff");
HttpResponse response2 = httpexec.execute(request2, conn);
System.out.println("<< Response: " + response2.getStatusLine());
System.out.println(EntityUtils.toString(response2.getEntity()));
System.out.println("==============");
if (connStrategy.keepAlive(response2)) {