diff --git a/lib/src/client.dart b/lib/src/client.dart index d4bc86e..2aabe99 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -825,26 +825,35 @@ class Client { try { switch (type.toString().split('.').last) { case "GET": - resp = await httpClient - .get(url, headers: headers) - .timeout(Duration(seconds: timeout)); + resp = await httpClient.get(url, headers: headers).timeout( + Duration(seconds: timeout), + onTimeout: () => null, + ); break; case "POST": - resp = await httpClient - .post(url, body: json, headers: headers) - .timeout(Duration(seconds: timeout)); + resp = + await httpClient.post(url, body: json, headers: headers).timeout( + Duration(seconds: timeout), + onTimeout: () => null, + ); break; case "PUT": - resp = await httpClient - .put(url, body: json, headers: headers) - .timeout(Duration(seconds: timeout)); + resp = + await httpClient.put(url, body: json, headers: headers).timeout( + Duration(seconds: timeout), + onTimeout: () => null, + ); break; case "DELETE": - resp = await httpClient - .delete(url, headers: headers) - .timeout(Duration(seconds: timeout)); + resp = await httpClient.delete(url, headers: headers).timeout( + Duration(seconds: timeout), + onTimeout: () => null, + ); break; } + if (resp == null) { + throw TimeoutException; + } jsonResp = jsonDecode(String.fromCharCodes(resp.body.runes)) as Map; // May throw FormatException diff --git a/pubspec.lock b/pubspec.lock index 30ef5f6..bbc0327 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -196,7 +196,7 @@ packages: name: http url: "https://pub.dartlang.org" source: hosted - version: "0.12.0+2" + version: "0.12.0+4" http_multi_server: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index e3c0281..7296819 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -8,7 +8,7 @@ environment: sdk: ">=2.7.0 <3.0.0" dependencies: - http: ^0.12.0+2 + http: ^0.12.0+4 mime_type: ^0.2.4 canonical_json: ^1.0.0