This commit is contained in:
Ashita Prasad
2024-12-21 10:19:34 +05:30
parent 8fbf8908f5
commit 1df49bd727
7 changed files with 34 additions and 38 deletions

View File

@@ -14,7 +14,6 @@ const kAssetSendingLottie = "assets/sending.json";
const kAssetSavingLottie = "assets/saving.json";
const kAssetSavedLottie = "assets/completed.json";
final kIsMacOS = !kIsWeb && Platform.isMacOS;
final kIsWindows = !kIsWeb && Platform.isWindows;
final kIsLinux = !kIsWeb && Platform.isLinux;

View File

@@ -1,5 +1,4 @@
import 'package:apidash_core/apidash_core.dart';
//import 'package:apidash_core/services/no_ssl_http_service.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:apidash/consts.dart';
import 'providers.dart';
@@ -280,7 +279,7 @@ class CollectionStateNotifier
requestId,
substitutedHttpRequestModel,
defaultUriScheme: defaultUriScheme,
noSSL: noSSL
noSSL: noSSL,
);
late final RequestModel newRequestModel;

View File

@@ -1,7 +1,7 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:apidash_design_system/apidash_design_system.dart';
import 'package:flutter/foundation.dart';
import '../providers/providers.dart';
import '../services/services.dart';
import '../utils/utils.dart';
@@ -25,9 +25,9 @@ class SettingsPage extends ConsumerWidget {
child: kIsDesktop
? Text("Settings",
style: Theme.of(context).textTheme.headlineLarge)
: const SizedBox.shrink(),
: kSizedBoxEmpty,
)
: const SizedBox.shrink(),
: kSizedBoxEmpty,
kIsDesktop
? const Padding(
padding: kPh20,
@@ -35,24 +35,26 @@ class SettingsPage extends ConsumerWidget {
height: 1,
),
)
: const SizedBox.shrink(),
: kSizedBoxEmpty,
Expanded(
child: ListView(
shrinkWrap: true,
children: [
!kIsWeb ?SwitchListTile(
!kIsWeb
? SwitchListTile(
hoverColor: kColorTransparent,
title: const Text('Disabling SSL verification'),
title: const Text('Disable SSL verification'),
subtitle: Text(
'Current selection: ${settings.isSSLDisabled ? "SSL Verification Disabled" : "SSL Verification Enabled"}',
),
value: settings.isSSLDisabled,
onChanged: (bool? value) {
ref.read(settingsProvider.notifier).update(isSSLDisabled: value ?? false);
ref
.read(settingsProvider.notifier)
.update(isSSLDisabled: value ?? false);
},
) :const SizedBox.shrink(),
)
: kSizedBoxEmpty,
SwitchListTile(
hoverColor: kColorTransparent,
title: const Text('Switch Theme Mode'),

View File

@@ -1,8 +1,15 @@
import 'package:apidash_core/utils/http_request_utils.dart';
import 'dart:io';
import 'dart:collection';
import 'package:flutter/foundation.dart';
import 'package:http/http.dart' as http;
import 'dart:collection';
import '';
import 'package:http/io_client.dart';
http.Client createHttpClientWithNoSSL() {
var ioClient = HttpClient()
..badCertificateCallback =
(X509Certificate cert, String host, int port) => true;
return IOClient(ioClient);
}
class HttpClientManager {
static final HttpClientManager _instance = HttpClientManager._internal();
@@ -16,14 +23,16 @@ class HttpClientManager {
HttpClientManager._internal();
http.Client createClient(String requestId,{bool noSSL = false}) {
final client = noSSL && !kIsWeb ? createHttpClientWithNoSSL() :http.Client();
http.Client createClient(
String requestId, {
bool noSSL = false,
}) {
final client =
(noSSL && !kIsWeb) ? createHttpClientWithNoSSL() : http.Client();
_clients[requestId] = client;
return client;
}
void cancelRequest(String? requestId) {
if (requestId != null && _clients.containsKey(requestId)) {
_clients[requestId]?.close();

View File

@@ -9,11 +9,12 @@ import '../utils/utils.dart';
import 'http_client_manager.dart';
typedef HttpResponse = http.Response;
Future<(HttpResponse?, Duration?, String?)> request(
String requestId,
HttpRequestModel requestModel, {
SupportedUriSchemes defaultUriScheme = kDefaultUriScheme,
bool noSSL = false, // Add a parameter to specify SSL-bypass
bool noSSL = false,
}) async {
final clientManager = HttpClientManager();
final client = clientManager.createClient(requestId, noSSL: noSSL);
@@ -73,7 +74,6 @@ Future<(HttpResponse?, Duration?, String?)> request(
return (convertedMultiPartResponse, stopwatch.elapsed, null);
}
}
switch (requestModel.method) {
case HTTPVerb.get:
response = await client.get(requestUrl, headers: headers);

View File

@@ -1,3 +1,2 @@
export 'http_client_manager.dart';
export 'http_service.dart';

View File

@@ -1,18 +1,6 @@
import 'dart:io';
import 'package:collection/collection.dart';
import 'package:http/http.dart' as http;
import 'package:http/io_client.dart';
import 'package:seed/seed.dart';
http.Client createHttpClientWithNoSSL() {
var ioClient = HttpClient()
..badCertificateCallback =
(X509Certificate cert, String host, int port) => true;
return IOClient(ioClient);
}
Map<String, String>? rowsToMap(
List<NameValueModel>? kvRows, {
bool isHeader = false,