Refactor auth handling in HTTP request functions

Removed redundant AuthModel parameter from sendHttpRequest and streamHttpRequest functions, now using authModel from HttpRequestModel directly. Updated all usages, tests, and related logic to reflect this change. Improved streaming response handling in CollectionStateNotifier and HttpResponseModel.
This commit is contained in:
Ankit Mahato
2025-08-06 02:42:23 +05:30
parent 81e967b1b3
commit 625254b20f
10 changed files with 52 additions and 102 deletions

View File

@@ -54,10 +54,10 @@ class _BetterNetworkingExampleState extends State<BetterNetworkingExample> {
final (resp, duration, err) = await sendHttpRequest(
'G1',
APIType.rest,
AuthModel(type: APIAuthType.none),
HttpRequestModel(
url: 'https://reqres.in/api/users/2',
method: HTTPVerb.get,
authModel: AuthModel(type: APIAuthType.none),
headers: [
NameValueModel(
name: 'x-api-key',
@@ -81,10 +81,10 @@ class _BetterNetworkingExampleState extends State<BetterNetworkingExample> {
final (resp, duration, err) = await sendHttpRequest(
'P1',
APIType.rest,
AuthModel(type: APIAuthType.none),
HttpRequestModel(
url: 'https://reqres.in/api/users',
method: HTTPVerb.post,
authModel: AuthModel(type: APIAuthType.none),
headers: [
NameValueModel(
name: 'x-api-key',
@@ -109,10 +109,10 @@ class _BetterNetworkingExampleState extends State<BetterNetworkingExample> {
final stream = await streamHttpRequest(
'S1',
APIType.rest,
null,
HttpRequestModel(
method: HTTPVerb.post,
url: 'http://localhost:11434/v1/chat/completions',
authModel: null,
body: jsonEncode({
'model': 'gemma3:latest',
'stream': true,