fixed stalled requests after app resume
This commit is contained in:
@@ -12,6 +12,10 @@ import '../nextcloud_ocs.dart';
|
||||
import 'talk_error.dart';
|
||||
|
||||
abstract class TalkApi<T extends ApiResponse?> {
|
||||
// package:http has no timeout of its own; a request stuck on a dead
|
||||
// connection (e.g. one started right before a suspend) would spin forever.
|
||||
static const Duration _timeout = Duration(seconds: 30);
|
||||
|
||||
String path;
|
||||
ApiParams? body;
|
||||
Map<String, String>? headers;
|
||||
@@ -35,7 +39,7 @@ abstract class TalkApi<T extends ApiResponse?> {
|
||||
|
||||
final data = await sendGuarded(
|
||||
'Talk $endpoint',
|
||||
() => request(endpoint, body, mergedHeaders),
|
||||
() => request(endpoint, body, mergedHeaders)?.timeout(_timeout),
|
||||
);
|
||||
if (data == null) {
|
||||
throw const NetworkException(
|
||||
|
||||
Reference in New Issue
Block a user