title: Handling HttpClient Redirects
body: <p>I'm POSTing some data to a server that is answering a 302 Moved Temporarily.</p>
  
  <p>I want HttpClient to follow the redirect and automatically GET the new location, as I believe it's the default behaviour of HttpClient. However, I'm getting an exception and not following the redirect :(</p>
  
  <p>Here's the relevant piece of code, any ideas will be appreciated:</p>
  
  <pre><code>HttpParams httpParams = new BasicHttpParams();
  HttpClientParams.setRedirecting(httpParams, true);
  SchemeRegistry schemeRegistry = registerFactories();
  ClientConnectionManager clientConnectionManager = new ThreadSafeClientConnManager(httpParams, schemeRegistry);
  
  HttpClient httpClient = new DefaultHttpClient(clientConnectionManager, httpParams)
  HttpPost postRequest = new HttpPost(url);
  postRequest.setHeader(HTTP.CONTENT_TYPE, contentType);
  postRequest.setHeader(ACCEPT, contentType);
  
  if (requestBodyString != null) {
      postRequest.setEntity(new StringEntity(requestBodyString));
  }
  
  return httpClient.execute(postRequest, responseHandler);
  </code></pre>