You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I encountered an issue with an HTTP request in version 1.2.1. Here is the original function I used:
Future getRequest(String url) async {
var headers = {
'Authorization': 'Bearer $token',
'Accept': '/',
'Accept-Encoding': 'gzip, deflate, br',
'Connection': 'keep-alive'
};
final apiUrl = Uri.parse(base_url + url);
// return await get(apiUrl, headers: headers);
final response = await retry(
// Make a GET request
() => get(apiUrl, headers: headers).timeout(const Duration(seconds: 15)),
// Retry on SocketException or TimeoutException
retryIf: (e) => e is SocketException || e is TimeoutException,
);
return response;
}
To resolve the issue, I made the following change:
Future getRequest(String url) async {
var headers = {
'Authorization': 'Bearer $token',
'Accept': '/',
// 'Accept-Encoding': 'gzip, deflate, br',
'Connection': 'keep-alive'
};
final apiUrl = Uri.parse(base_url + url);
// return await get(apiUrl, headers: headers);
final response = await retry(
// Make a GET request
() => get(apiUrl, headers: headers).timeout(const Duration(seconds: 15)),
// Retry on SocketException or TimeoutException
retryIf: (e) => e is SocketException || e is TimeoutException,
);
return response;
}
By simply removing 'Accept-Encoding': 'gzip, deflate, br' from the headers, the body of the response was understood correctly again.
The text was updated successfully, but these errors were encountered:
sdk: '>=3.4.0 <4.0.0'
http: ^1.2.1
I encountered an issue with an HTTP request in version 1.2.1. Here is the original function I used:
Future getRequest(String url) async {
var headers = {
'Authorization': 'Bearer $token',
'Accept': '/',
'Accept-Encoding': 'gzip, deflate, br',
'Connection': 'keep-alive'
};
final apiUrl = Uri.parse(base_url + url);
// return await get(apiUrl, headers: headers);
final response = await retry(
// Make a GET request
() => get(apiUrl, headers: headers).timeout(const Duration(seconds: 15)),
// Retry on SocketException or TimeoutException
retryIf: (e) => e is SocketException || e is TimeoutException,
);
return response;
}
To resolve the issue, I made the following change:
Future getRequest(String url) async {
var headers = {
'Authorization': 'Bearer $token',
'Accept': '/',
// 'Accept-Encoding': 'gzip, deflate, br',
'Connection': 'keep-alive'
};
final apiUrl = Uri.parse(base_url + url);
// return await get(apiUrl, headers: headers);
final response = await retry(
// Make a GET request
() => get(apiUrl, headers: headers).timeout(const Duration(seconds: 15)),
// Retry on SocketException or TimeoutException
retryIf: (e) => e is SocketException || e is TimeoutException,
);
return response;
}
By simply removing 'Accept-Encoding': 'gzip, deflate, br' from the headers, the body of the response was understood correctly again.
The text was updated successfully, but these errors were encountered: