final String _authString;
AuthClient(
username,
password, {
BaseClient http1Client,
bool autoUncompress = true,
bool maintainOpenConnections = true,
int maxOpenConnections = -1,
Function onBadCertificate,
SecurityContext context,
Duration timeout,
}) : _authString = _getAuthString(username, password),
super(
http1Client: http1Client,
autoUncompress: autoUncompress,
maintainOpenConnections: maintainOpenConnections,
maxOpenConnections: maxOpenConnections,
onBadCertificate: onBadCertificate,
context: context,
timeout: const Duration(seconds: 60),
);
static String _getAuthString(username, password) {
final token = base64Encode(utf8.encode('$username:$password'));
return "Basic ${token.trim()}";
}
BaseRequest _setHeaders(BaseRequest request) => request
..headers[HttpHeaders.authorizationHeader] = _authString
..headers[HttpHeaders.contentLengthHeader] =
request.contentLength.toString();
@override
Future<StreamedResponse> send(BaseRequest request) {
return super.send(_setHeaders(request));
}
}
AuthClient c = AuthClient("username", "password",
maxOpenConnections: Platform.numberOfProcessors);
Response response = await c.get(url);
c.close();
This is just one request.
It also happens when I do multiple:
c = AuthClient("username", "password");
return Future.wait([
c.get(url1),
c.get(url2),
c.get(url3),
]);
I'm not sure why this is happening.
I really hope you can help me, or point me in the right direction.