feed method

void feed(
  1. List<int> bytes
)

Add raw bytes from the transport.

Implementation

void feed(List<int> bytes) {
  if (bytes.isEmpty) return;
  if (_pendingFatalError != null) return;
  // Avoid copying a caller-supplied giant chunk merely to discover from an
  // already-present header that a frame is invalid. Scan complete virtual
  // frame boundaries across buffered + incoming bytes, including a split
  // leading header and later frames after a valid prefix. Without this
  // preflight, either shape could make `_ensureWritable` copy the hostile
  // chunk before `drain` rejected its declared length.
  final preflightError = _preflightPayloadLengths(bytes);
  if (preflightError != null) {
    _pendingFatalError = preflightError;
    return;
  }
  _ensureWritable(bytes.length);
  _buffer.setRange(_end, _end + bytes.length, bytes);
  _end += bytes.length;
}