code: protected byte[] convertInputStreamToByteArray(InputStream in) throws IOException {
          ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
          int c = -1;
          while ((c = in.read()) != -1) {
              outputStream.write(c);
          }
          outputStream.flush();
          in.close();
          return outputStream.toByteArray();
      }
docs: /*this is required to fix proxy authentication retry failure
  caused by org.apache.http.client.NonRepeatableRequestException: Cannot retry request with a non-repeatable request entity