From 9fddb1cd4080c89079b13bf8b8b53ca9d0fad322 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Wed, 27 Mar 2024 13:32:15 -0700 Subject: [PATCH] Fix the connectionInfo getter (#1163) --- .../http_profile/lib/src/http_client_request_profile.dart | 5 +++-- pkgs/http_profile/lib/src/http_profile_response_data.dart | 3 --- .../test/http_client_request_profile_test.dart | 8 ++++---- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/pkgs/http_profile/lib/src/http_client_request_profile.dart b/pkgs/http_profile/lib/src/http_client_request_profile.dart index 3d2372ba01..9b7b2157e3 100644 --- a/pkgs/http_profile/lib/src/http_client_request_profile.dart +++ b/pkgs/http_profile/lib/src/http_client_request_profile.dart @@ -115,10 +115,11 @@ final class HttpClientRequestProfile { } Map? get connectionInfo => - requestData._data['connectionInfo'] == null + requestData._requestData['connectionInfo'] == null ? null : UnmodifiableMapView( - requestData._data['connectionInfo'] as Map, + requestData._requestData['connectionInfo'] + as Map, ); /// Details about the request. diff --git a/pkgs/http_profile/lib/src/http_profile_response_data.dart b/pkgs/http_profile/lib/src/http_profile_response_data.dart index 5eb452adcb..8cf0f682d6 100644 --- a/pkgs/http_profile/lib/src/http_profile_response_data.dart +++ b/pkgs/http_profile/lib/src/http_profile_response_data.dart @@ -68,9 +68,6 @@ final class HttpProfileResponseData { List get bodyBytes => UnmodifiableListView(_data['responseBodyBytes'] as List); - Map? get connectionInfo => - _responseData['connectionInfo'] as Map?; - /// The response headers where duplicate headers are represented using a list /// of values. /// diff --git a/pkgs/http_profile/test/http_client_request_profile_test.dart b/pkgs/http_profile/test/http_client_request_profile_test.dart index fdba3e3a6b..7422bffc20 100644 --- a/pkgs/http_profile/test/http_client_request_profile_test.dart +++ b/pkgs/http_profile/test/http_client_request_profile_test.dart @@ -83,7 +83,7 @@ void main() { final responseData = backingMap['responseData'] as Map; expect(requestData['connectionInfo'], isNull); expect(responseData['connectionInfo'], isNull); - expect(profile.responseData.connectionInfo, isNull); + expect(profile.connectionInfo, isNull); profile.connectionInfo = { 'localPort': 1285, @@ -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'); @@ -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'); @@ -137,6 +137,6 @@ void main() { expect(requestData['connectionInfo'], isNull); expect(responseData['connectionInfo'], isNull); - expect(profile.responseData.connectionInfo, isNull); + expect(profile.connectionInfo, isNull); }); }