persistentConnection property

  1. @override
bool get persistentConnection
override

Whether the connection is persistent (keep-alive).

Implementation

@override
bool get persistentConnection => _persistentConnection;
  1. @override
set persistentConnection (bool persistentConnection)
override

Whether the connection is persistent (keep-alive).

Implementation

@override
set persistentConnection(bool persistentConnection) {
  _checkMutable();
  if (persistentConnection == _persistentConnection) return;
  final originalName = _originalHeaderName(HttpHeaders.connectionHeader);
  if (persistentConnection) {
    if (protocolVersion == "1.1") {
      remove(HttpHeaders.connectionHeader, "close");
    } else {
      if (_contentLength < 0) {
        throw HttpException(
            "Trying to set 'Connection: Keep-Alive' on HTTP 1.0 headers with "
            "no ContentLength");
      }
      add(originalName, "keep-alive", preserveHeaderCase: true);
    }
  } else {
    if (protocolVersion == "1.1") {
      add(originalName, "close", preserveHeaderCase: true);
    } else {
      remove(HttpHeaders.connectionHeader, "keep-alive");
    }
  }
  _persistentConnection = persistentConnection;
}