stream method
Sends a request and yields decoded text chunks as they arrive.
Implementations should throw AiHttpException for non-success responses when a streaming request cannot continue.
Implementation
Stream<String> stream(AiHttpRequest request) async* {
final response = await send(request);
if (!response.isSuccess) {
throw AiHttpException(
'Streaming request failed with status ${response.statusCode}',
);
}
if (response.body.isNotEmpty) {
yield response.body;
}
}