Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ class RestTransport implements DataConnectTransport {
'Content-Type': 'application/json',
'Accept': 'application/json',
'x-goog-api-client': getGoogApiVal(sdkType, packageVersion),
'x-firebase-client': getFirebaseClientVal(packageVersion)
'x-firebase-client': getFirebaseClientVal(packageVersion),
'x-client-platform': 'flutter',
'x-client-version': packageVersion,
};
String? appCheckToken;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,16 @@ class WebSocketTransport implements DataConnectTransport {

bool get isConnected => _channel != null;

@visibleForTesting
Map<String, String> buildHeaders(String? authToken, String? appCheckToken) =>
_buildHeaders(authToken, appCheckToken);

Map<String, String> _buildHeaders(String? authToken, String? appCheckToken) {
Map<String, String> headers = {
'x-goog-api-client': getGoogApiVal(sdkType, packageVersion),
'x-firebase-client': getFirebaseClientVal(packageVersion)
'x-firebase-client': getFirebaseClientVal(packageVersion),
'x-client-platform': 'flutter',
'x-client-version': packageVersion
};
if (authToken != null) {
headers['X-Firebase-Auth-Token'] = authToken;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,80 @@ void main() {
).called(1);
});

test(
'invokeOperation should include x-client-platform headers',
() async {
final mockResponse = http.Response('{"data": {"key": "value"}}', 200);
when(
mockHttpClient.post(
any,
headers: anyNamed('headers'),
body: anyNamed('body'),
),
).thenAnswer((_) async => mockResponse);

String deserializer(String data) => 'Deserialized Data';

await transport.invokeOperation(
'testQuery',
'executeQuery',
deserializer,
null,
null,
'authToken123',
);

verify(
mockHttpClient.post(
any,
headers: argThat(
allOf(
containsPair('x-client-platform', 'flutter'),
),
named: 'headers',
),
body: anyNamed('body'),
),
).called(1);
});

test(
'invokeOperation should include x-client-version headers',
() async {
final mockResponse = http.Response('{"data": {"key": "value"}}', 200);
when(
mockHttpClient.post(
any,
headers: anyNamed('headers'),
body: anyNamed('body'),
),
).thenAnswer((_) async => mockResponse);

String deserializer(String data) => 'Deserialized Data';

await transport.invokeOperation(
'testQuery',
'executeQuery',
deserializer,
null,
null,
'authToken123',
);

verify(
mockHttpClient.post(
any,
headers: argThat(
allOf(
containsPair('x-client-version', packageVersion),
),
named: 'headers',
),
body: anyNamed('body'),
),
).called(1);
});

test(
'regression #17290 - invokeOperation should correctly decode UTF-8 response with international characters',
() async {
Expand Down
Loading