@Override
    public void onDataAvailable(DataEmitter emitter, ByteBufferList bb) {
      if (cached != null) {
        com.koushikdutta.async.Util.emitAllData(this, cached);
        // couldn't emit it all, so just wait for another day...
        if (cached.remaining() > 0) return;
        cached = null;
      }

      // write to cache... any data not consumed needs to be retained for the next callback
      try {
        if (cacheRequest != null) {
          OutputStream outputStream = cacheRequest.getBody();
          if (outputStream != null) {
            int count = bb.size();
            for (int i = 0; i < count; i++) {
              ByteBuffer b = bb.remove();
              outputStream.write(b.array(), b.arrayOffset() + b.position(), b.remaining());
              bb.add(b);
            }
          } else {
            abort();
          }
        }
      } catch (Exception e) {
        abort();
      }

      super.onDataAvailable(emitter, bb);

      if (cacheRequest != null && bb.remaining() > 0) {
        cached = new ByteBufferList();
        cached.add(bb);
        bb.clear();
      }
    }
 @Override
 public void write(ByteBufferList bb) {
   // it's gonna write headers and stuff... whatever
   bb.clear();
 }
 @Override
 public void onDataAvailable(DataEmitter emitter, ByteBufferList bb) {
   if (data == null) data = new ByteBufferList();
   data.add(bb);
   bb.clear();
 }