@@ -140,18 +140,18 @@ class ClientIO extends ClientBase with ClientMixin {
140
140
Future init () async {
141
141
if (_initProgress) return ;
142
142
_initProgress = true ;
143
- // if web skip cookie implementation and origin header as those are automatically handled by browsers
144
143
final Directory cookieDir = await _getCookiePath ();
145
144
_cookieJar = PersistCookieJar (storage: FileStorage (cookieDir.path));
146
145
_interceptors.add (CookieManager (_cookieJar));
147
- PackageInfo packageInfo = await PackageInfo .fromPlatform ();
148
- addHeader ('Origin' ,
149
- 'appwrite-${Platform .operatingSystem }://${packageInfo .packageName }' );
150
146
151
- //creating custom user agent
152
- DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin ();
153
147
var device = '' ;
154
148
try {
149
+ PackageInfo packageInfo = await PackageInfo .fromPlatform ();
150
+ addHeader ('Origin' ,
151
+ 'appwrite-${Platform .operatingSystem }://${packageInfo .packageName }' );
152
+
153
+ //creating custom user agent
154
+ DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin ();
155
155
if (Platform .isAndroid) {
156
156
final andinfo = await deviceInfoPlugin.androidInfo;
157
157
device =
@@ -174,12 +174,14 @@ class ClientIO extends ClientBase with ClientMixin {
174
174
final macinfo = await deviceInfoPlugin.macOsInfo;
175
175
device = '(Macintosh; ${macinfo .model })' ;
176
176
}
177
+ addHeader (
178
+ 'user-agent' , '${packageInfo .packageName }/${packageInfo .version } $device ' );
177
179
} catch (e) {
178
180
debugPrint ('Error getting device info: $e ' );
179
181
device = Platform .operatingSystem;
182
+ addHeader (
183
+ 'user-agent' , '$device ' );
180
184
}
181
- addHeader (
182
- 'user-agent' , '${packageInfo .packageName }/${packageInfo .version } $device ' );
183
185
184
186
_initialized = true ;
185
187
_initProgress = false ;
0 commit comments