@Override
    public InputStream getInput() throws IOException {
      if (connection != null) {
        InputStream is = connection.getInputStream();
        connection = null;

        // Handle a bug in older versions of Android, see
        // http://android-developers.blogspot.se/2010/07/multithreading-for-performance.html
        if (!Android.isAPI(9)) {
          is = new FlushedInputStream(is);
        }

        return is;
      } else {
        return openConnection(url).getInputStream();
      }
    }
 /**
  * Workaround for bug pre-Froyo, see here for more info:
  * http://android-developers.blogspot.com/2011/09/androids-http-clients.html
  */
 private static void disableConnectionReuseIfNecessary() {
   // HTTP connection reuse which was buggy pre-froyo
   if (!Android.isAPI(8)) {
     System.setProperty("http.keepAlive", "false");
   }
 }
 @TargetApi(14)
 private void tag(int tag) {
   if (Android.isAPI(14)) {
     TrafficStats.setThreadStatsTag(tag);
   }
 }