feat(http): [WIP] work on middleware feature

This commit is contained in:
2022-06-23 11:48:32 +02:00
parent 9e9ec9ba9b
commit ea4a30ca00
14 changed files with 1349 additions and 13 deletions
@@ -0,0 +1,87 @@
// Copyright (C) 2022 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import 'dart:convert';
import 'dart:typed_data';
import 'package:http/http.dart';
import 'package:wyatt_http_client/src/implemented_base_client.dart';
abstract class AuthenticatedClient implements ImplementedBaseClient {
final Client _inner;
AuthenticatedClient({
Client? inner,
}) : _inner = inner ?? Client();
@override
void close() => _inner.close();
@override
Future<Response> head(Uri url, {Map<String, String>? headers}) =>
_inner.head(url, headers: headers);
@override
Future<Response> get(Uri url, {Map<String, String>? headers}) =>
_inner.get(url, headers: headers);
@override
Future<Response> post(
Uri url, {
Map<String, String>? headers,
Object? body,
Encoding? encoding,
}) =>
_inner.post(url, headers: headers, body: body, encoding: encoding);
@override
Future<Response> put(
Uri url, {
Map<String, String>? headers,
Object? body,
Encoding? encoding,
}) =>
_inner.put(url, headers: headers, body: body, encoding: encoding);
@override
Future<Response> patch(
Uri url, {
Map<String, String>? headers,
Object? body,
Encoding? encoding,
}) =>
_inner.patch(url, headers: headers, body: body, encoding: encoding);
@override
Future<Response> delete(
Uri url, {
Map<String, String>? headers,
Object? body,
Encoding? encoding,
}) =>
_inner.delete(url, headers: headers, body: body, encoding: encoding);
@override
Future<String> read(Uri url, {Map<String, String>? headers}) =>
_inner.read(url, headers: headers);
@override
Future<Uint8List> readBytes(Uri url, {Map<String, String>? headers}) =>
_inner.readBytes(url, headers: headers);
@override
Future<StreamedResponse> send(BaseRequest request) => _inner.send(request);
}
@@ -14,8 +14,161 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import 'dart:convert';
import 'dart:typed_data';
import 'package:http/http.dart';
import 'package:wyatt_http_client/src/mixins/body_transformer.dart';
import 'package:wyatt_http_client/src/mixins/headers_transformer.dart';
import 'package:wyatt_http_client/src/rest_client.dart';
import 'package:wyatt_http_client/src/utils/protocols.dart';
import 'package:wyatt_http_client/src/utils/utils.dart';
class AwesomeClient extends BaseClient {
final Client _inner;
AwesomeClient({
Client? inner,
}) : _inner = inner ?? Client();
@override
Future<StreamedResponse> send(BaseRequest request) {
return _inner.send(request);
}
}
class AwesomeRestClient extends AwesomeClient
with HeadersTransformer, BodyTransformer {
final Protocols protocol;
final String? authority;
AwesomeRestClient({
this.protocol = Protocols.https,
this.authority = '',
super.inner,
});
@override
Object? bodyMutator(Object? body) {
print('bodyMutator: Json encoding');
return jsonEncode(body);
}
@override
Map<String, String>? headersMutator(
Object? body,
Map<String, String>? headers,
) {
print('headerMutator: Json encoding');
final mutation = {
'content-type': 'application/json; charset=utf-8',
};
if (headers != null) {
headers.addAll(mutation);
return headers;
} else {
return mutation;
}
}
@override
BaseRequest requestMutator(BaseRequest request) {
print('requestMutator: scheme + authority');
final Uri uri = Uri.parse('${protocol.scheme}$authority${request.url}');
return Utils.copyRequestWith(request, url: uri);
}
}
class AwesomeUrlClient extends AuthenticatedClient {
AwesomeUrlClient(super.inner);
}
class AwesomeOauth2Client extends AuthenticatedClient with HeadersTransformer {
AwesomeOauth2Client(super.inner);
@override
Map<String, String>? headersMutator(
Object? body,
Map<String, String>? headers,
) {
print('headersMutator: Token manager');
final mutation = {
'authorization': 'Bearer TOKEN',
};
if (headers != null) {
headers.addAll(mutation);
return headers;
} else {
return mutation;
}
}
}
abstract class AuthenticatedClient implements Client {
final Client _inner;
Client get inner => _inner;
AuthenticatedClient(BaseClient? inner) : _inner = inner ?? RestClient();
@override
void close() => _inner.close();
@override
Future<Response> head(Uri url, {Map<String, String>? headers}) =>
_inner.head(url, headers: headers);
@override
Future<Response> get(Uri url, {Map<String, String>? headers}) =>
_inner.get(url, headers: headers);
@override
Future<Response> post(
Uri url, {
Map<String, String>? headers,
Object? body,
Encoding? encoding,
}) =>
_inner.post(url, headers: headers, body: body, encoding: encoding);
@override
Future<Response> put(
Uri url, {
Map<String, String>? headers,
Object? body,
Encoding? encoding,
}) =>
_inner.put(url, headers: headers, body: body, encoding: encoding);
@override
Future<Response> patch(
Uri url, {
Map<String, String>? headers,
Object? body,
Encoding? encoding,
}) =>
_inner.patch(url, headers: headers, body: body, encoding: encoding);
@override
Future<Response> delete(
Uri url, {
Map<String, String>? headers,
Object? body,
Encoding? encoding,
}) =>
_inner.delete(url, headers: headers, body: body, encoding: encoding);
@override
Future<String> read(Uri url, {Map<String, String>? headers}) =>
_inner.read(url, headers: headers);
@override
Future<Uint8List> readBytes(Uri url, {Map<String, String>? headers}) =>
_inner.readBytes(url, headers: headers);
@override
Future<StreamedResponse> send(BaseRequest request) => _inner.send(request);
}
abstract class AuthenticationClient extends BaseClient {
final BaseClient _inner;
@@ -24,6 +177,50 @@ abstract class AuthenticationClient extends BaseClient {
AuthenticationClient(BaseClient? inner) : _inner = inner ?? RestClient();
@override
Future<Response> head(Uri url, {Map<String, String>? headers}) =>
_inner.head(url, headers: headers);
@override
Future<Response> get(Uri url, {Map<String, String>? headers}) =>
_inner.get(url, headers: headers);
@override
Future<Response> post(
Uri url, {
Map<String, String>? headers,
Object? body,
Encoding? encoding,
}) =>
_inner.post(url, headers: headers, body: body, encoding: encoding);
@override
Future<Response> put(
Uri url, {
Map<String, String>? headers,
Object? body,
Encoding? encoding,
}) =>
_inner.put(url, headers: headers, body: body, encoding: encoding);
@override
Future<Response> patch(
Uri url, {
Map<String, String>? headers,
Object? body,
Encoding? encoding,
}) =>
_inner.patch(url, headers: headers, body: body, encoding: encoding);
@override
Future<Response> delete(
Uri url, {
Map<String, String>? headers,
Object? body,
Encoding? encoding,
}) =>
_inner.delete(url, headers: headers, body: body, encoding: encoding);
@override
Future<StreamedResponse> send(BaseRequest request) {
return _inner.send(request);
@@ -31,6 +31,7 @@ abstract class HeaderAuthenticationClient extends AuthenticationClient {
final newHeader = modifyHeader(Map.from(request.headers), request);
request.headers.clear();
request.headers.addAll(newHeader);
print(newHeader);
return super.send(request);
}
}
@@ -14,6 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import 'package:http/http.dart';
import 'package:wyatt_http_client/src/authentication/interfaces/header_authentication_client.dart';
typedef TokenParser = String Function(Map<String, dynamic>);
@@ -21,14 +22,14 @@ typedef TokenParser = String Function(Map<String, dynamic>);
abstract class Oauth2Client extends HeaderAuthenticationClient {
Oauth2Client(super.inner);
Future<void> refresh() {
Future<Response?> refresh() {
return Future.value();
}
Future<void> authorize(
Future<Response> authorize(
Map<String, dynamic> body, {
Map<String, String>? headers,
}) {
return Future.value();
return Future<Response>.value();
}
}
@@ -23,6 +23,78 @@ import 'package:wyatt_http_client/src/utils/header_keys.dart';
import 'package:wyatt_http_client/src/utils/http_status.dart';
import 'package:wyatt_http_client/src/utils/utils.dart';
// class Oauth2Client extends ImplementedBaseClient with RequestTransformer {
// final String authorizationEndpoint;
// final String tokenEndpoint;
// String? accessToken;
// String? refreshToken;
// String? tokenToUse;
// Oauth2Client({
// required this.authorizationEndpoint,
// required this.tokenEndpoint,
// this.accessToken,
// this.refreshToken,
// super.inner,
// }) : tokenToUse = accessToken;
// @override
// BaseRequest requestMutator(BaseRequest request) {
// print('Oauth2Client::requestMutator -> add authorization: $accessToken');
// final headers = request.headers;
// final mutation = {
// 'Authorization': 'Bearer $tokenToUse',
// };
// if (tokenToUse?.isNotEmpty ?? false) {
// headers.addAll(mutation);
// return Utils.copyRequestWith(request, headers: headers);
// }
// return request;
// }
// Future<Response?> refresh() async {
// if (refreshToken?.isNotEmpty ?? false) {
// tokenToUse = refreshToken;
// final response = await get(
// Uri.parse(tokenEndpoint),
// );
// if (response.statusCode == HttpStatus.ok) {
// // final body = json.decode(response.body) as Map<String, dynamic>;
// // accessToken = accessTokenParser(body);
// print('Oauth2Client::refresh -> ok');
// }
// return response;
// }
// return null;
// }
// @override
// Map<String, String>? headersMutator(
// Object? body,
// Map<String, String>? headers,
// ) {
// print(
// 'Oauth2Client::headersMutator -> add authorization: $accessToken',
// );
// final mutation = {
// 'Authorization': 'Bearer $accessToken',
// };
// if (accessToken.isNotEmpty) {
// if (headers != null) {
// headers.addAll(mutation);
// return headers;
// } else {
// return mutation;
// }
// } else {
// return headers;
// }
// }
// }
class RefreshTokenClient extends Oauth2Client {
final String authorizationEndpoint;
final String tokenEndpoint;
@@ -50,6 +122,8 @@ class RefreshTokenClient extends Oauth2Client {
Map<String, String> header, [
BaseRequest? request,
]) {
print('accessToken $accessToken');
print('request $request');
if (accessToken != null && request != null) {
header[authenticationHeader] = '$authenticationMethod $accessToken';
return header;
@@ -58,13 +132,13 @@ class RefreshTokenClient extends Oauth2Client {
}
@override
Future<void> authorize(
Future<Response> authorize(
Map<String, dynamic> body, {
Map<String, String>? headers,
}) async {
final response = await inner.post(
Uri.parse(authorizationEndpoint),
body: jsonEncode(body),
body: body,
headers: headers,
);
@@ -80,10 +154,11 @@ class RefreshTokenClient extends Oauth2Client {
this.refreshToken = refreshToken;
}
}
return response;
}
@override
Future<void> refresh() async {
Future<Response?> refresh() async {
if (refreshToken != null) {
final Map<String, String> header = {
authenticationHeader: '$authenticationHeader $refreshToken',
@@ -98,11 +173,16 @@ class RefreshTokenClient extends Oauth2Client {
final body = json.decode(response.body) as Map<String, dynamic>;
accessToken = accessTokenParser(body);
}
return response;
}
return null;
}
@override
Future<StreamedResponse> send(BaseRequest request) async {
final newHeader = modifyHeader(Map.from(request.headers), request);
request.headers.clear();
request.headers.addAll(newHeader);
final response = await super.send(request);
if (response.statusCode == HttpStatus.unauthorized) {
@@ -0,0 +1,31 @@
// Copyright (C) 2022 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import 'package:http/http.dart';
class ImplementedBaseClient extends BaseClient {
final Client inner;
ImplementedBaseClient({
Client? inner,
}) : inner = inner ?? Client();
@override
Future<StreamedResponse> send(BaseRequest request) {
return inner.send(request);
}
}
@@ -0,0 +1,86 @@
// Copyright (C) 2022 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import 'dart:convert';
import 'dart:typed_data';
import 'package:http/http.dart';
abstract class ImplementedClient extends BaseClient {
final Client _inner;
ImplementedClient({
Client? inner,
}) : _inner = inner ?? Client();
@override
void close() => _inner.close();
@override
Future<Response> head(Uri url, {Map<String, String>? headers}) =>
_inner.head(url, headers: headers);
@override
Future<Response> get(Uri url, {Map<String, String>? headers}) =>
_inner.get(url, headers: headers);
@override
Future<Response> post(
Uri url, {
Map<String, String>? headers,
Object? body,
Encoding? encoding,
}) =>
_inner.post(url, headers: headers, body: body, encoding: encoding);
@override
Future<Response> put(
Uri url, {
Map<String, String>? headers,
Object? body,
Encoding? encoding,
}) =>
_inner.put(url, headers: headers, body: body, encoding: encoding);
@override
Future<Response> patch(
Uri url, {
Map<String, String>? headers,
Object? body,
Encoding? encoding,
}) =>
_inner.patch(url, headers: headers, body: body, encoding: encoding);
@override
Future<Response> delete(
Uri url, {
Map<String, String>? headers,
Object? body,
Encoding? encoding,
}) =>
_inner.delete(url, headers: headers, body: body, encoding: encoding);
@override
Future<String> read(Uri url, {Map<String, String>? headers}) =>
_inner.read(url, headers: headers);
@override
Future<Uint8List> readBytes(Uri url, {Map<String, String>? headers}) =>
_inner.readBytes(url, headers: headers);
@override
Future<StreamedResponse> send(BaseRequest request) => _inner.send(request);
}
@@ -0,0 +1,83 @@
// Copyright (C) 2022 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import 'dart:convert';
import 'package:http/http.dart';
mixin BodyTransformer on Client {
Object? bodyMutator(Object? body);
@override
Future<Response> post(
Uri url, {
Map<String, String>? headers,
Object? body,
Encoding? encoding,
}) {
return super.post(
url,
headers: headers,
body: bodyMutator(body),
encoding: encoding,
);
}
@override
Future<Response> put(
Uri url, {
Map<String, String>? headers,
Object? body,
Encoding? encoding,
}) {
return super.put(
url,
headers: headers,
body: bodyMutator(body),
encoding: encoding,
);
}
@override
Future<Response> patch(
Uri url, {
Map<String, String>? headers,
Object? body,
Encoding? encoding,
}) {
return super.patch(
url,
headers: headers,
body: bodyMutator(body),
encoding: encoding,
);
}
@override
Future<Response> delete(
Uri url, {
Map<String, String>? headers,
Object? body,
Encoding? encoding,
}) {
return super.delete(
url,
headers: headers,
body: bodyMutator(body),
encoding: encoding,
);
}
}
@@ -0,0 +1,131 @@
// Copyright (C) 2022 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import 'dart:convert';
import 'dart:typed_data';
import 'package:http/http.dart';
mixin HeadersTransformer on Client {
Map<String, String>? headersMutator(
Object? body,
Map<String, String>? headers,
);
@override
Future<Response> head(
Uri url, {
Map<String, String>? headers,
}) {
return super.head(
url,
headers: headersMutator(null, headers),
);
}
@override
Future<Response> get(
Uri url, {
Map<String, String>? headers,
}) {
return super.get(
url,
headers: headersMutator(null, headers),
);
}
@override
Future<Response> post(
Uri url, {
Map<String, String>? headers,
Object? body,
Encoding? encoding,
}) {
return super.post(
url,
headers: headersMutator(body, headers),
body: body,
encoding: encoding,
);
}
@override
Future<Response> put(
Uri url, {
Map<String, String>? headers,
Object? body,
Encoding? encoding,
}) {
return super.put(
url,
headers: headersMutator(body, headers),
body: body,
encoding: encoding,
);
}
@override
Future<Response> patch(
Uri url, {
Map<String, String>? headers,
Object? body,
Encoding? encoding,
}) {
return super.patch(
url,
headers: headersMutator(body, headers),
body: body,
encoding: encoding,
);
}
@override
Future<Response> delete(
Uri url, {
Map<String, String>? headers,
Object? body,
Encoding? encoding,
}) {
return super.delete(
url,
headers: headersMutator(body, headers),
body: body,
encoding: encoding,
);
}
@override
Future<String> read(
Uri url, {
Map<String, String>? headers,
}) {
return super.read(
url,
headers: headersMutator(null, headers),
);
}
@override
Future<Uint8List> readBytes(
Uri url, {
Map<String, String>? headers,
}) {
return super.readBytes(
url,
headers: headersMutator(null, headers),
);
}
}
@@ -0,0 +1,33 @@
// Copyright (C) 2022 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import 'package:http/http.dart';
import 'package:wyatt_http_client/src/implemented_base_client.dart';
mixin Oauth2Transformer on ImplementedBaseClient {
late final String authorizationEndpoint;
late final String tokenEndpoint;
String? accessToken;
String? refreshToken;
BaseRequest requestAuthenticator(BaseRequest request);
@override
Future<StreamedResponse> send(BaseRequest request) {
final req = requestAuthenticator(request);
return super.send(req);
}
}
@@ -0,0 +1,27 @@
// Copyright (C) 2022 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import 'package:http/http.dart';
import 'package:wyatt_http_client/src/implemented_base_client.dart';
mixin RequestTransformer on ImplementedBaseClient {
BaseRequest requestMutator(BaseRequest request);
@override
Future<StreamedResponse> send(BaseRequest request) {
return super.send(requestMutator(request));
}
}
@@ -14,25 +14,177 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import 'dart:convert';
import 'package:http/http.dart';
import 'package:wyatt_http_client/src/implemented_base_client.dart';
import 'package:wyatt_http_client/src/mixins/body_transformer.dart';
import 'package:wyatt_http_client/src/mixins/headers_transformer.dart';
import 'package:wyatt_http_client/src/mixins/request_transformer.dart';
import 'package:wyatt_http_client/src/utils/protocols.dart';
import 'package:wyatt_http_client/src/utils/utils.dart';
class RestClient extends BaseClient {
class RestClient extends ImplementedBaseClient
with BodyTransformer, HeadersTransformer, RequestTransformer {
final Protocols protocol;
final String? authority;
final Client _inner;
RestClient({
this.protocol = Protocols.https,
this.authority = '',
Client? inner,
}) : _inner = inner ?? Client();
super.inner,
});
@override
Future<StreamedResponse> send(BaseRequest request) {
Object? bodyMutator(Object? body) {
print(
'RestClient::bodyMutator -> encode in json if body is Map: ${body is Map}',
);
if (body is Map) {
return jsonEncode(body);
}
return body;
}
@override
Map<String, String>? headersMutator(
Object? body,
Map<String, String>? headers,
) {
print(
'RestClient::headersMutator -> add json content-type if body is Map: ${body is Map}',
);
final mutation = {
'content-type': 'application/json; charset=utf-8',
};
if (body is Map) {
if (headers != null) {
headers.addAll(mutation);
return headers;
} else {
return mutation;
}
}
return headers;
}
@override
BaseRequest requestMutator(BaseRequest request) {
print(
'RestClient::requestMutator -> add prefix path: ${protocol.scheme}$authority',
);
final Uri uri = Uri.parse('${protocol.scheme}$authority${request.url}');
return _inner.send(Utils.copyRequestWith(request, url: uri));
return Utils.copyRequestWith(request, url: uri);
}
}
// class RestClient extends BaseClient {
// final Protocols protocol;
// final String? authority;
// final Client _inner;
// RestClient({
// this.protocol = Protocols.https,
// this.authority = '',
// Client? inner,
// }) : _inner = inner ?? Client();
// String? forceJson(Object? body) {
// String? b;
// if (body != null && body is Map) {
// b = jsonEncode(body);
// }
// return b;
// }
// Map<String, String>? forceJsonHeader(
// Object? body, Map<String, String>? headers,) {
// final Map<String, String> h = headers ?? {};
// if (body != null && body is Map) {
// h['Content-Type'] = 'application/json';
// }
// return h;
// }
// // @override
// // Future<Response> post(
// // Uri url, {
// // Map<String, String>? headers,
// // Object? body,
// // Encoding? encoding,
// // }) {
// // final b = forceJson(body) ?? body;
// // final h = forceJsonHeader(body, headers) ?? headers;
// // print(b);
// // print(h);
// // return super.post(
// // url,
// // headers: h,
// // body: b,
// // encoding: encoding,
// // );
// // }
// @override
// Future<Response> put(
// Uri url, {
// Map<String, String>? headers,
// Object? body,
// Encoding? encoding,
// }) {
// final b = forceJson(body) ?? body;
// final h = forceJsonHeader(body, headers) ?? headers;
// return super.put(
// url,
// headers: h,
// body: b,
// encoding: encoding,
// );
// }
// @override
// Future<Response> patch(
// Uri url, {
// Map<String, String>? headers,
// Object? body,
// Encoding? encoding,
// }) {
// final b = forceJson(body) ?? body;
// final h = forceJsonHeader(body, headers) ?? headers;
// return super.patch(
// url,
// headers: h,
// body: b,
// encoding: encoding,
// );
// }
// @override
// Future<Response> delete(
// Uri url, {
// Map<String, String>? headers,
// Object? body,
// Encoding? encoding,
// }) {
// final b = forceJson(body) ?? body;
// final h = forceJsonHeader(body, headers) ?? headers;
// return super.delete(
// url,
// headers: h,
// body: b,
// encoding: encoding,
// );
// }
// @override
// Future<StreamedResponse> send(BaseRequest request) {
// final Uri uri = Uri.parse('${protocol.scheme}$authority${request.url}');
// return _inner.send(
// Utils.copyRequestWith(
// request,
// url: uri,
// ),
// );
// }
// }