Merge branch 'main' into add-request-cancellation

This commit is contained in:
Ashita Prasad
2024-12-15 07:51:01 +05:30
committed by GitHub
98 changed files with 3873 additions and 1414 deletions

View File

@@ -13,7 +13,7 @@ enum SupportedUriSchemes { https, http }
final kSupportedUriSchemes =
SupportedUriSchemes.values.map((i) => i.name).toList();
const kDefaultUriScheme = "https";
const kDefaultUriScheme = SupportedUriSchemes.https;
final kLocalhostRegex = RegExp(r'^localhost(:\d+)?(/.*)?$');
const kMethodsWithBody = [

View File

@@ -12,7 +12,7 @@ typedef HttpResponse = http.Response;
Future<(HttpResponse?, Duration?, String?)> request(
HttpRequestModel requestModel, {
String defaultUriScheme = kDefaultUriScheme,
SupportedUriSchemes defaultUriScheme = kDefaultUriScheme,
String? requestId,
}) async {
final clientManager = HttpClientManager();

View File

@@ -5,7 +5,7 @@ import 'http_request_utils.dart';
(String?, bool) getUriScheme(Uri uri) {
if (uri.hasScheme) {
if (kSupportedUriSchemes.contains(uri.scheme)) {
if (kSupportedUriSchemes.contains(uri.scheme.toLowerCase())) {
return (uri.scheme, true);
}
return (uri.scheme, false);
@@ -24,7 +24,7 @@ String stripUrlParams(String url) {
(Uri?, String?) getValidRequestUri(
String? url, List<NameValueModel>? requestParams,
{String defaultUriScheme = kDefaultUriScheme}) {
{SupportedUriSchemes defaultUriScheme = kDefaultUriScheme}) {
url = url?.trim();
if (url == null || url == "") {
return (null, "URL is missing!");
@@ -44,7 +44,7 @@ String stripUrlParams(String url) {
return (null, "Unsupported URL Scheme (${urlScheme.$1})");
}
} else {
url = "$defaultUriScheme://$url";
url = "${defaultUriScheme.name}://$url";
}
uri = Uri.parse(url);