private DataInputStream serAndPrepForRead(RequestOrResponse requestOrResponse) throws IOException {
    DataInputStream stream;
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    do {
      ByteBufferChannel channel = new ByteBufferChannel(ByteBuffer.allocate((int) requestOrResponse.sizeInBytes()));
      requestOrResponse.writeTo(channel);
      ByteBuffer underlyingBuf = channel.getBuffer();
      underlyingBuf.flip();
      outputStream.write(underlyingBuf.array(), underlyingBuf.arrayOffset(), underlyingBuf.remaining());
    } while (!requestOrResponse.isSendComplete());
    stream = new DataInputStream(new ByteArrayInputStream(outputStream.toByteArray()));
    // read length
    stream.readLong();
    return stream;
  }
Test for undelete request and response.
@throws IOException
ambry-network/src/test/java/com/github/ambry/network/ServerRequestResponseHelperTest.java