code: private void ensureCapacity(int headerSize) throws IOException {
      while (size + headerSize > capacity) {
        int index = length();
        if (index == 0) {
          break;
        }
        remove();
      }
    }
docs: Ensure that the dynamic table has enough room to hold 'headerSize' more bytes.
  Removes the oldest entry from the dynamic table until sufficient space is available.