Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 10th, 2012  |  syntax: None  |  size: 0.91 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.        <dependency>
  2.             <groupId>org.apache.httpcomponents</groupId>
  3.             <artifactId>httpclient</artifactId>
  4.             <version>4.0</version>
  5.         </dependency>
  6.  
  7. ===========================================
  8.  
  9. IList<string> arrayOfUrls; // fille this up
  10.  
  11. MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
  12.  
  13.    HttpConnectionManagerParams params = new HttpConnectionManagerParams();
  14.         params.setConnectionTimeout(20);
  15.         params.setDefaultMaxConnectionsPerHost(20);
  16.         params.setMaxTotalConnections(10);
  17.  
  18.         connectionManager.setParams(params);
  19.  
  20.  
  21.  
  22. HttpClient client = new HttpClient(connectionManager);
  23.  
  24.  
  25.  
  26. foreach url in arrayOfUrls {
  27.  
  28.         GetMethod get = new GetMethod(url);
  29.         int returnCode = client.executeMethod(method);
  30.         if(returnCode == 200)
  31.         {
  32.                 String location=get.getResponseHeader("location").getValue();
  33.         }
  34.  
  35.  
  36. }