getConfig method
Implementation
Future<MeshagentDeploymentConfig> getConfig() async {
final request = http.Request('GET', Uri.parse('${baseUrl.replaceFirst(RegExp(r'/+$'), '')}/config'))..followRedirects = false;
final streamed = await httpClient.send(request);
final data = BytesBuilder(copy: false);
await for (final chunk in streamed.stream) {
if (data.length + chunk.length > 1024 * 1024) throw MeshagentException('Deployment config response exceeds its size limit');
data.add(chunk);
}
final response = http.Response.bytes(data.takeBytes(), streamed.statusCode, headers: streamed.headers);
if (response.statusCode != 200) throw MeshagentException.fromResponse('Unable to read deployment config.', response);
return MeshagentDeploymentConfig.fromJson((jsonDecode(response.body) as Map).cast<String, dynamic>());
}