sendRequestKeepingProgress<T extends Result?> method
Sends a request to the server, and answers it from this connection's response cache where the 2026-07-28 caching rules allow it.
sendRequest and sendRequestWithInputs both go through here, so a
resources/read that later retries still consults the cache. A request
is cached when its _meta names 2026-07-28, or when it leaves the
version out and this connection settled on that revision. Cached answers
drop when the matching list-changed or resource-updated notification
arrives, when a paginated request reports its cursor is no longer valid,
and on shutdown.
Implementation
@protected
@override
Future<T> sendRequestKeepingProgress<T extends Result?>(
String methodName, [
Request? request,
]) {
final meta = (request as Map<String, Object?>?)?[Keys.meta];
final version =
meta is Map<String, Object?> ? meta[Keys.protocolVersionMeta] : null;
// Only `discover` names the revision in its own metadata. Every other
// request leaves it out and the negotiated version is what says whether
// the answer can be reused.
final onRevision =
version == ProtocolVersion.v2026_07_28.versionString ||
(version == null && protocolVersion == ProtocolVersion.v2026_07_28);
if (!onRevision) {
return super.sendRequestKeepingProgress<T>(methodName, request);
}
return _responseCache.sendRequest<T>(
methodName,
request,
() => super.sendRequestKeepingProgress<T>(methodName, request),
);
}