@Override
 public void writeInto(OutputStream responseBody) throws IOException {
   try {
     CountingOutputStream c = new CountingOutputStream(responseBody);
     IOUtils.copy(entity, c);
     this.length = c.getCount();
   } finally {
     IOUtils.closeQuietly(entity);
   }
 }
 @Override
 public long getContentLength() {
   if (this.length == Long.MIN_VALUE) {
     if (ByteArrayInputStream.class.isInstance(entity)
         || FileInputStream.class.isInstance(entity)) {
       length = IOUtils.avairable(entity);
     } else {
       length = -1;
     }
   }
   return length;
 }