title: Setting a timeout value when retrieving data via HttpGet object
body: <p>I have some Java code that I 'inherited' from a previous co-worker.  Part of it connects to an outside URL using method GET and retrieves a small amount of XML for parsing.  We've been having issues recently with this connection crashing our website due to the vendor website hanging and using up resources on our side. One issue is due to no timeouts being set when our code uses the HttpGet object.  Is there a way to fine-tune timeouts using this object, or is there a better way to pull back this XML?</p>
  
  <p>Would I be better off using another API?</p>
  
  <pre><code>List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;();
  params.add(new BasicNameValuePair("param1","foobar"));
  URI uri = URIUtils.createURI("http", "myhost.com", -1, "mypath",
  URLEncodedUtils.format(params, "UTF-8"), null);
  
  // there is no timeout here??
  HttpGet httpGet = new HttpGet(uri);
  HttpClient httpClient = new DefaultHttpClient();
  HttpResponse httpResponse = httpClient.execute(httpGet);
  String result = IOUtils.toString(httpResponse.getEntity()
      .getContent(), "UTF-8");
  </code></pre>
  
  <p>Thanks!</p>