getDocument static method
Get a document (client-side)
Implementation
static Future<DocumentFrameResponse> getDocument(
P2PStream stream, {
required PeerId ownerPeerId,
required String path,
String? ifNoneMatch,
}) async {
try {
final headers = <String, String>{};
if (ifNoneMatch != null) {
headers['If-None-Match'] = ifNoneMatch;
}
final requestBytes = DocumentFrame.encodeRequest(
operation: 'GET',
ownerPeerId: ownerPeerId,
path: path,
headers: headers,
);
await _writeFrameStatic(stream, requestBytes);
// Read response
final responseBytes = await _readFrameStatic(stream);
return DocumentFrame.decodeResponse(responseBytes);
} catch (e, stackTrace) {
_logger.severe('Error getting document: $e', e, stackTrace);
rethrow;
}
}