title: Android waking up from sleep mode causes ClientProtocolException for http calls
body: <p>When the device goes into "sleep" or power saving mode (screen goes black) when you hit the power button to restore the screen, all looks well and functions. However when I attempt to do any HTTP calls (using <code>DefaultHttpClient</code>) I get <code>ClientProtocolException</code>exceptions. I then have to exit the application and come back in, and everything works fine. I know there is the new URLConnection package available, but the refactor will take sometime. Is there any way to correct this?</p>
  
  <p>Here is a sample of the code that fails, but again, it works just fine until the device sleeps:</p>
  
  <pre><code>public JSONObject mediaAmazonUploadAuthParams(String key, String contentType, Boolean publicRead) throws MyException {
      JSONObject authParams = null;
      HttpClient httpClient = new DefaultHttpClient();
      ResponseHandler&lt;String&gt; responseHandler = new BasicResponseHandler();
      HttpPost postMethod = new HttpPost(getBaseUrl() + "myapi");  
      postMethod.setHeader("SessionToken", mSessionToken);
      int versionCode = Utilities.getVersionCode(GlobalState.getInstance().context);
      String versionName = "0.0.0";
      String clientHeader = "android-0.0.0"; 
      postMethod.setHeader("Client", clientHeader);
      postMethod.setHeader( "Content-Type", "application/json");
  
      GatekeeperResult result;
      JSONObject postJson = new JSONObject();
      try {
          postJson.put("key", key);
          postJson.put("contentType", contentType);
          postJson.put("publicRead", publicRead);
          String postString = postJson.toString();
          postMethod.setEntity(new StringEntity(postString));
          String response = httpClient.execute(postMethod, responseHandler);
          result = new Result(new JSONObject(response));
      } catch (Exception e) {
          Log.e("Client","mediaAmazonUploadAuthParams(), Error httpClient execute ",e);
          throw new MyException(e);
      }
  </code></pre>
  
  <p>Here is the stack trace I get on failure.</p>
  
  <pre><code>05-28 11:36:20.891: E/GatekeeperApiClient(8999): org.apache.http.client.ClientProtocolException
  05-28 11:36:20.891: E/GatekeeperApiClient(8999):    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:589)
  05-28 11:36:20.891: E/GatekeeperApiClient(8999):    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:685)
  05-28 11:36:20.891: E/GatekeeperApiClient(8999):    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:659)
  05-28 11:36:20.891: E/GatekeeperApiClient(8999):    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:648)
  05-28 11:36:20.891: E/GatekeeperApiClient(8999):    at com.invocore.fastfield.gatekeeper.GatekeeperApiClient.mediaAmazonUploadAuthParams(GatekeeperApiClient.java:906)
  05-28 11:36:20.891: E/GatekeeperApiClient(8999):    at com.invocore.fastfield.utility.LibraryUtils.saveFormMedia(LibraryUtils.java:156)
  05-28 11:36:20.891: E/GatekeeperApiClient(8999):    at com.invocore.fastfield.FormActivity$submitFormResultTask.doInBackground(FormActivity.java:2562)
  05-28 11:36:20.891: E/GatekeeperApiClient(8999):    at com.invocore.fastfield.FormActivity$submitFormResultTask.doInBackground(FormActivity.java:1)
  05-28 11:36:20.891: E/GatekeeperApiClient(8999):    at android.os.AsyncTask$2.call(AsyncTask.java:287)
  05-28 11:36:20.891: E/GatekeeperApiClient(8999):    at java.util.concurrent.FutureTask.run(FutureTask.java:234)
  05-28 11:36:20.891: E/GatekeeperApiClient(8999):    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
  05-28 11:36:20.891: E/GatekeeperApiClient(8999):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
  05-28 11:36:20.891: E/GatekeeperApiClient(8999):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
  05-28 11:36:20.891: E/GatekeeperApiClient(8999):    at java.lang.Thread.run(Thread.java:838)
  05-28 11:36:20.891: E/GatekeeperApiClient(8999): Caused by: org.apache.http.ProtocolException: Received redirect response HTTP/1.1 301 Moved Permanently but no location header
  05-28 11:36:20.891: E/GatekeeperApiClient(8999):    at org.apache.http.impl.client.DefaultRedirectHandler.getLocationURI(DefaultRedirectHandler.java:103)
  05-28 11:36:20.891: E/GatekeeperApiClient(8999):    at org.apache.http.impl.client.DefaultRequestDirector.handleResponse(DefaultRequestDirector.java:944)
  05-28 11:36:20.891: E/GatekeeperApiClient(8999):    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:491)
  05-28 11:36:20.891: E/GatekeeperApiClient(8999):    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:587)
  05-28 11:36:20.891: E/GatekeeperApiClient(8999):    ... 13 more
  </code></pre>
  
  <p>NOTE: This does not happen on only the screen going to sleep...also is a factor of time (over 10 minutes idle). Think it may be related to something getting pulled form memory because of idleness? 
  Thanks in advance!</p>