Browse Source

dynamite,nextcloud: Fix setting user agent

pull/148/head
jld3103 2 years ago
parent
commit
63bb2c8fcb
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 8
      packages/dynamite/lib/src/openapi_builder.dart
  2. 2
      packages/nextcloud/lib/src/client.dart
  3. 3
      packages/nextcloud/lib/src/nextcloud.openapi.dart

8
packages/dynamite/lib/src/openapi_builder.dart

@ -395,6 +395,12 @@ class OpenAPIBuilder implements Builder {
..type = refer('Map<String, String>?') ..type = refer('Map<String, String>?')
..named = true, ..named = true,
), ),
Parameter(
(final b) => b
..name = 'userAgent'
..type = refer('String?')
..named = true,
),
Parameter( Parameter(
(final b) => b (final b) => b
..name = 'httpClient' ..name = 'httpClient'
@ -427,7 +433,7 @@ class OpenAPIBuilder implements Builder {
}, },
''' : ''} ''' : ''}
}; };
this.httpClient = httpClient ?? HttpClient(); this.httpClient = (httpClient ?? HttpClient())..userAgent = userAgent;
'''), '''),
), ),
) )

2
packages/nextcloud/lib/src/client.dart

@ -16,9 +16,9 @@ class NextcloudClient extends Client {
'OCS-APIRequest': 'true', 'OCS-APIRequest': 'true',
'Accept': 'application/json', 'Accept': 'application/json',
'Accept-Language': language, 'Accept-Language': language,
'User-Agent': userAgentOverride ?? appType.userAgent,
}..removeWhere((final _, final value) => value == null)) }..removeWhere((final _, final value) => value == null))
.cast<String, String>(), .cast<String, String>(),
userAgent: userAgentOverride ?? appType.userAgent,
authentication: username != null && password != null authentication: username != null && password != null
? HttpBasicAuthentication( ? HttpBasicAuthentication(
username: username, username: username,

3
packages/nextcloud/lib/src/nextcloud.openapi.dart

@ -93,6 +93,7 @@ class Client {
Client( Client(
this.baseURL, { this.baseURL, {
Map<String, String>? baseHeaders, Map<String, String>? baseHeaders,
String? userAgent,
HttpClient? httpClient, HttpClient? httpClient,
this.cookieJar, this.cookieJar,
this.authentication, this.authentication,
@ -105,7 +106,7 @@ class Client {
...authentication!.headers, ...authentication!.headers,
}, },
}; };
this.httpClient = httpClient ?? HttpClient(); this.httpClient = (httpClient ?? HttpClient())..userAgent = userAgent;
} }
final String baseURL; final String baseURL;

Loading…
Cancel
Save