2024-08-17 23:39:20 +00:00
|
|
|
import 'dart:math';
|
|
|
|
|
2024-08-18 22:02:04 +00:00
|
|
|
import 'package:flutter/foundation.dart';
|
2023-09-23 19:09:36 +00:00
|
|
|
import 'package:http/http.dart' as http;
|
|
|
|
|
|
|
|
class UserAgentClient extends http.BaseClient {
|
|
|
|
final String userAgent;
|
|
|
|
final http.Client _inner;
|
|
|
|
|
|
|
|
UserAgentClient(this.userAgent, this._inner);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Future<http.StreamedResponse> send(http.BaseRequest request) {
|
|
|
|
request.headers['user-agent'] = userAgent;
|
2024-08-18 22:02:04 +00:00
|
|
|
if (!kIsWeb) request.headers['X-Session-ID'] = "${Random().nextInt(1<<32)}";
|
2023-09-23 19:09:36 +00:00
|
|
|
return _inner.send(request);
|
|
|
|
}
|
|
|
|
}
|