public static JSONObject getJsonizedResponseBody(ReadableStreamChannel channel) throws Exception {
    RetainingAsyncWritableChannel asyncWritableChannel = new RetainingAsyncWritableChannel((int) channel.getSize());
    channel.readInto(asyncWritableChannel, null).get();
    try (InputStream is = asyncWritableChannel.consumeContentAsInputStream()) {
      return new JSONObject(new String(Utils.readBytesFromStream(is, (int) asyncWritableChannel.getBytesWritten())));
    }
  }
Reads the response received from the {@code channel} and decodes it into a {@link JSONObject}.
@param channel the {@link ReadableStreamChannel} that contains the response
@return the response decoded into a {@link JSONObject}.
@throws Exception
ambry-rest/src/test/java/com/github/ambry/rest/RestTestUtils.java