close method

Signals the end of the stream. Completes a close-delimited response body, and reports any incomplete buffered bytes as pass-through.

Implementation

List<HttpStreamEvent> close() {
  final out = <HttpStreamEvent>[];
  if (_state == _State.closeBody) {
    _state = _State.head;
    out.add(HttpMessageEndEvent());
  }
  if (_buf.isNotEmpty) {
    out.add(HttpPassthroughEvent(_buf));
    _buf = Uint8List(0);
    _state = _State.passthrough;
  }
  return out;
}