Skip to content

Commit

Permalink
Fix the connectionInfo getter (#1163)
Browse files Browse the repository at this point in the history
  • Loading branch information
brianquinlan authored Mar 27, 2024
1 parent 9f47439 commit 9fddb1c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
5 changes: 3 additions & 2 deletions pkgs/http_profile/lib/src/http_client_request_profile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,11 @@ final class HttpClientRequestProfile {
}

Map<String, dynamic /*String|int*/ >? get connectionInfo =>
requestData._data['connectionInfo'] == null
requestData._requestData['connectionInfo'] == null
? null
: UnmodifiableMapView(
requestData._data['connectionInfo'] as Map<String, dynamic>,
requestData._requestData['connectionInfo']
as Map<String, dynamic>,
);

/// Details about the request.
Expand Down
3 changes: 0 additions & 3 deletions pkgs/http_profile/lib/src/http_profile_response_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ final class HttpProfileResponseData {
List<int> get bodyBytes =>
UnmodifiableListView(_data['responseBodyBytes'] as List<int>);

Map<String, dynamic /*String|int*/ >? get connectionInfo =>
_responseData['connectionInfo'] as Map<String, dynamic>?;

/// The response headers where duplicate headers are represented using a list
/// of values.
///
Expand Down
8 changes: 4 additions & 4 deletions pkgs/http_profile/test/http_client_request_profile_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void main() {
final responseData = backingMap['responseData'] as Map<String, dynamic>;
expect(requestData['connectionInfo'], isNull);
expect(responseData['connectionInfo'], isNull);
expect(profile.responseData.connectionInfo, isNull);
expect(profile.connectionInfo, isNull);

profile.connectionInfo = {
'localPort': 1285,
Expand All @@ -102,7 +102,7 @@ void main() {
expect(connectionInfoFromRequestData['connectionPoolId'], '21x23');
expect(connectionInfoFromResponseData['connectionPoolId'], '21x23');

final connectionInfoFromGetter = profile.responseData.connectionInfo!;
final connectionInfoFromGetter = profile.connectionInfo!;
expect(connectionInfoFromGetter['localPort'], 1285);
expect(connectionInfoFromGetter['remotePort'], 443);
expect(connectionInfoFromGetter['connectionPoolId'], '21x23');
Expand All @@ -128,7 +128,7 @@ void main() {
expect(connectionInfoFromRequestData['connectionPoolId'], '21x23');
expect(connectionInfoFromResponseData['connectionPoolId'], '21x23');

final connectionInfoFromGetter = profile.responseData.connectionInfo!;
final connectionInfoFromGetter = profile.connectionInfo!;
expect(connectionInfoFromGetter['localPort'], 1285);
expect(connectionInfoFromGetter['remotePort'], 443);
expect(connectionInfoFromGetter['connectionPoolId'], '21x23');
Expand All @@ -137,6 +137,6 @@ void main() {

expect(requestData['connectionInfo'], isNull);
expect(responseData['connectionInfo'], isNull);
expect(profile.responseData.connectionInfo, isNull);
expect(profile.connectionInfo, isNull);
});
}

0 comments on commit 9fddb1c

Please sign in to comment.