chore: fix and format using melos

This commit is contained in:
2023-02-23 19:19:48 +01:00
parent d098d9a6bf
commit 8d833d39d7
152 changed files with 441 additions and 468 deletions
@@ -25,7 +25,6 @@ import 'package:wyatt_http_client/src/pipeline.dart';
import 'package:wyatt_http_client/src/utils/http_methods.dart';
class MiddlewareClient extends BaseClient {
MiddlewareClient({
Pipeline? pipeline,
Client? inner,
@@ -1,16 +1,15 @@
// 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/>.
@@ -23,7 +23,6 @@ import 'package:wyatt_http_client/src/utils/authentication_methods.dart';
import 'package:wyatt_http_client/src/utils/header_keys.dart';
class BasicAuthMiddleware with OnRequestMiddleware implements Middleware {
BasicAuthMiddleware({
this.username,
this.password,
@@ -25,7 +25,6 @@ import 'package:wyatt_http_client/src/utils/http_status.dart';
class DigestAuthMiddleware
with OnRequestMiddleware, OnResponseMiddleware
implements Middleware {
DigestAuthMiddleware({
required this.username,
required this.password,
@@ -1,16 +1,16 @@
// 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/>.
@@ -31,7 +31,6 @@ typedef TokenParser = String Function(Map<String, dynamic>);
class RefreshTokenAuthMiddleware
with OnRequestMiddleware, OnResponseMiddleware
implements Middleware {
RefreshTokenAuthMiddleware({
required this.authorizationEndpoint,
required this.tokenEndpoint,
@@ -20,7 +20,6 @@ import 'package:wyatt_http_client/src/models/middleware_request.dart';
import 'package:wyatt_http_client/src/utils/convert.dart';
class UnsafeAuthMiddleware with OnRequestMiddleware implements Middleware {
UnsafeAuthMiddleware({
this.username,
this.password,
@@ -20,7 +20,6 @@ import 'package:wyatt_http_client/src/models/middleware_request.dart';
import 'package:wyatt_http_client/src/utils/protocols.dart';
class UriPrefixMiddleware with OnRequestMiddleware implements Middleware {
UriPrefixMiddleware({
required this.protocol,
required this.authority,
@@ -44,15 +44,19 @@ class MiddlewareContext {
MiddlewareRequest? lastRequest,
MiddlewareResponse? originalResponse,
MiddlewareResponse? lastResponse,
}) => MiddlewareContext(
pipeline: pipeline ?? this.pipeline,
client: client ?? this.client,
originalRequest: originalRequest ?? this.originalRequest,
lastRequest: lastRequest ?? this.lastRequest,
originalResponse: originalResponse ?? this.originalResponse,
lastResponse: lastResponse ?? this.lastResponse,
);
}) =>
MiddlewareContext(
pipeline: pipeline ?? this.pipeline,
client: client ?? this.client,
originalRequest: originalRequest ?? this.originalRequest,
lastRequest: lastRequest ?? this.lastRequest,
originalResponse: originalResponse ?? this.originalResponse,
lastResponse: lastResponse ?? this.lastResponse,
);
@override
String toString() => 'MiddlewareContext(pipeline: $pipeline, client: $client, originalRequest: $originalRequest, lastRequest: $lastRequest, originalResponse: $originalResponse, lastResponse: $lastResponse)';
String toString() =>
'MiddlewareContext(pipeline: $pipeline, client: $client, '
'originalRequest: $originalRequest, lastRequest: $lastRequest, '
'originalResponse: $originalResponse, lastResponse: $lastResponse)';
}
@@ -31,6 +31,7 @@ class MiddlewareResponse {
return '';
}
}
int? get contentLength => httpResponse.contentLength;
Map<String, String> get headers => httpResponse.headers;
@@ -40,11 +41,11 @@ class MiddlewareResponse {
MiddlewareResponse copyWith({
BaseResponse? httpResponse,
}) => MiddlewareResponse(
httpResponse: httpResponse ?? this.httpResponse,
);
}) =>
MiddlewareResponse(
httpResponse: httpResponse ?? this.httpResponse,
);
@override
String toString() =>
'MiddlewareResponse(httpResponse: $httpResponse)';
String toString() => 'MiddlewareResponse(httpResponse: $httpResponse)';
}
@@ -1,16 +1,16 @@
// 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/>.
@@ -17,7 +17,6 @@
import 'dart:convert';
class UnfreezedRequest {
UnfreezedRequest({
required this.method,
required this.url,
@@ -37,15 +36,16 @@ class UnfreezedRequest {
Map<String, String>? headers,
Object? body,
Encoding? encoding,
}) => UnfreezedRequest(
method: method ?? this.method,
url: url ?? this.url,
headers: headers ?? this.headers,
body: body ?? this.body,
encoding: encoding ?? this.encoding,
);
}) =>
UnfreezedRequest(
method: method ?? this.method,
url: url ?? this.url,
headers: headers ?? this.headers,
body: body ?? this.body,
encoding: encoding ?? this.encoding,
);
@override
String toString() => 'UnfreezedRequest(method: $method, url: $url, headers: '
'$headers, body: $body, encoding: $encoding)';
'$headers, body: $body, encoding: $encoding)';
}
@@ -20,7 +20,6 @@ import 'package:wyatt_http_client/src/models/middleware_request.dart';
import 'package:wyatt_http_client/src/models/middleware_response.dart';
class Pipeline {
Pipeline() : _middlewares = <Middleware>[];
Pipeline.fromIterable(Iterable<Middleware> middlewares)
: _middlewares = middlewares.toList();
@@ -65,8 +64,7 @@ class Pipeline {
MiddlewareContext ctx = context.copyWith(lastRequest: req);
for (final middleware in _middlewares) {
if (middleware is OnRequestMiddleware) {
req = await (middleware as OnRequestMiddleware)
.onRequest(ctx, request);
req = await (middleware as OnRequestMiddleware).onRequest(ctx, request);
ctx = context.copyWith(lastRequest: req);
}
}
@@ -34,10 +34,12 @@ class Convert {
static String mapToQuery(Map<String, String> map, {Encoding? encoding}) {
final pairs = <List<String>>[];
map.forEach((key, value) => pairs.add([
Uri.encodeQueryComponent(key, encoding: encoding ?? utf8),
Uri.encodeQueryComponent(value, encoding: encoding ?? utf8)
]),);
map.forEach(
(key, value) => pairs.add([
Uri.encodeQueryComponent(key, encoding: encoding ?? utf8),
Uri.encodeQueryComponent(value, encoding: encoding ?? utf8)
]),
);
return pairs.map((pair) => '${pair[0]}=${pair[1]}').join('&');
}
}
@@ -19,7 +19,8 @@ import 'dart:math';
import 'package:wyatt_http_client/src/utils/convert.dart';
import 'package:wyatt_http_client/src/utils/crypto.dart';
class DigestAuth { // request counter
class DigestAuth {
// request counter
DigestAuth(this.username, this.password);
String username;
@@ -22,7 +22,7 @@ enum HttpMethods {
patch('PATCH'),
delete('DELETE');
final String method;
const HttpMethods(this.method);
final String method;
}
@@ -81,10 +81,13 @@ enum HttpStatus {
// Client generated status code.
networkConnectTimeoutError(599);
final int statusCode;
const HttpStatus(this.statusCode);
factory HttpStatus.from(int status) =>
HttpStatus.values.firstWhere((element) => element.statusCode == status);
final int statusCode;
bool equals(Object other) {
if (other is HttpStatus) {
return statusCode == other.statusCode;
@@ -104,8 +107,4 @@ enum HttpStatus {
bool isClientError() => statusCode >= 400 && statusCode < 500;
bool isServerError() => statusCode >= 500 && statusCode < 600;
factory HttpStatus.from(int status) => HttpStatus.values
.firstWhere((element) => element.statusCode == status);
}
@@ -1,16 +1,16 @@
// 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/>.