Close HTTP connections

This commit is contained in:
Hillel Coren 2021-09-03 13:36:52 +03:00
parent c4dc934074
commit ec3ca7d959
3 changed files with 16 additions and 6 deletions

View File

@ -33,10 +33,12 @@ class WebClient {
url += '&per_page=999999';
}
final http.Response response = await http.Client().get(
final client = http.Client();
final http.Response response = await client.get(
Uri.parse(url),
headers: _getHeaders(url, token),
);
client.close();
if (rawResponse) {
return response;
@ -78,7 +80,8 @@ class WebClient {
if (multipartFiles != null) {
response = await _uploadFiles(url, token, multipartFiles, data: data);
} else {
response = await http.Client()
final client = http.Client();
response = await client
.post(
Uri.parse(url),
body: data,
@ -95,6 +98,7 @@ class WebClient {
seconds: rawResponse ? kMaxRawPostSeconds : kMaxPostSeconds,
),
);
client.close();
}
if (rawResponse) {
@ -133,7 +137,8 @@ class WebClient {
response = await _uploadFiles(url, token, [multipartFile],
fileIndex: fileIndex, data: data, method: 'PUT');
} else {
response = await http.Client().put(
final client = http.Client();
response = await client.put(
Uri.parse(url),
body: data,
headers: _getHeaders(
@ -143,6 +148,7 @@ class WebClient {
idToken: idToken,
),
);
client.close();
}
_checkResponse(response);
@ -166,7 +172,8 @@ class WebClient {
print('Delete: $url');
final http.Response response = await http.Client().delete(
final client = http.Client();
final http.Response response = await client.delete(
Uri.parse(url),
headers: _getHeaders(
url,
@ -175,6 +182,7 @@ class WebClient {
idToken: idToken,
),
);
client.close();
_checkResponse(response);

View File

@ -324,7 +324,9 @@ Future<Response> _loadPDF(
} else {
final invitation = invoice.invitations.first;
final url = invitation.downloadLink;
response = await http.Client().get(Uri.parse(url));
final client = http.Client();
response = await client.get(Uri.parse(url));
client.close();
}
if (response.statusCode >= 400) {

View File

@ -90,7 +90,7 @@ BEGIN
BLOCK "040904e4"
BEGIN
VALUE "CompanyName", "Invoice Ninja" "\0"
VALUE "FileDescription", "Invoice Clients, Track Work-Time, Get Paid Online." "\0"
VALUE "FileDescription", "Invoice Ninja" "\0"
VALUE "FileVersion", VERSION_AS_STRING "\0"
VALUE "InternalName", "invoiceninja" "\0"
VALUE "LegalCopyright", "Copyright (C) 2021 Invoice Ninja. All rights reserved." "\0"