-
Notifications
You must be signed in to change notification settings - Fork 386
Added size support to Network tab #9744
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Victowolf
wants to merge
14
commits into
flutter:master
Choose a base branch
from
Victowolf:feature/network-request-size
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b1b848c
Added size support to network tab
Victowolf aa06a0c
Added release notes entry for network response size feature
Victowolf 63e2041
Resolve merge conflict in release notes
Victowolf 49aa68b
Added documentation for byte formatting
Victowolf 249d990
Resolve merge conflict in release notes
Victowolf 4bb20f1
Fix lint: match parameter names with base class
Victowolf 1b4fc25
Fix lint: correct parameter name in AddressColumn
Victowolf ec2e7d9
Fix type handling for content-length header in responseBytes
Victowolf 3c17534
Fix layout spacing to ensure consistent widget tree
Victowolf 4257c47
Fix variable placement for response size rendering
Victowolf 6fb03f9
Fix parameter name to match ColumnData override
Victowolf b4a124b
Addressed Requested changes: update size units, refactor column defin…
Victowolf 71e3db3
Addressed Rquested Changes: refactor formatBytes into http_utils, upd…
Victowolf bfb9fb4
fix : formatBytes test fail
Victowolf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -227,6 +227,26 @@ class DartIOHttpRequestData extends NetworkRequest { | |
| return connectionInfo != null ? connectionInfo[_localPortKey] : null; | ||
| } | ||
|
|
||
| @override | ||
| int? get responseBytes { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a test for this
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, added tests in |
||
| final contentLength = responseHeaders?['content-length']; | ||
|
|
||
| if (contentLength is String) { | ||
| return int.tryParse(contentLength); | ||
| } | ||
| if (contentLength is List && contentLength.isNotEmpty) { | ||
| final first = contentLength.first; | ||
|
|
||
| if (first is int) { | ||
| return first; | ||
| } | ||
| if (first is String) { | ||
| return int.tryParse(first); | ||
| } | ||
| } | ||
| return null; | ||
| } | ||
|
|
||
| /// True if the HTTP request hasn't completed yet, determined by the lack of | ||
| /// an end time in the response data. | ||
| @override | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
packages/devtools_app/test/shared/http/http_request_data_test.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| import 'package:devtools_app/src/shared/http/http_request_data.dart'; | ||
| import 'package:flutter_test/flutter_test.dart'; | ||
|
|
||
| void main() { | ||
| group('responseBytes', () { | ||
| Map<String, dynamic> baseJson(Map<String, Object?> headers) { | ||
| return { | ||
| 'method': 'GET', | ||
| 'uri': 'https://example.com', | ||
| 'status': 200, | ||
| 'responseHeaders': headers, | ||
| }; | ||
| } | ||
|
|
||
| // Verifies parsing when content-length is a string value. | ||
| test('parses content-length from string', () { | ||
| final request = DartIOHttpRequestData.fromJson( | ||
| baseJson({'content-length': '1234'}), | ||
| null, // requestPostData not used for this test | ||
| null, // responseContent not used for this test | ||
| ); | ||
|
|
||
| expect(request.responseBytes, 1234); | ||
| }); | ||
|
|
||
| // Verifies parsing when content-length is a list of strings. | ||
| test('parses content-length from list of strings', () { | ||
| final request = DartIOHttpRequestData.fromJson( | ||
| baseJson({'content-length': '5678'}), | ||
| null, // requestPostData not used for this test | ||
| null, // responseContent not used for this test | ||
| ); | ||
|
|
||
| expect(request.responseBytes, 5678); | ||
| }); | ||
|
|
||
| // Ensures integer values inside a list are handled correctly. | ||
| test('handles integer in list', () { | ||
| final request = DartIOHttpRequestData.fromJson( | ||
| baseJson({'content-length': '91011'}), | ||
| null, // requestPostData not used for this test | ||
| null, // responseContent not used for this test | ||
| ); | ||
|
|
||
| expect(request.responseBytes, 91011); | ||
| }); | ||
|
|
||
| // Returns null when header is missing. | ||
| test('returns null for missing header', () { | ||
| final request = DartIOHttpRequestData.fromJson( | ||
| baseJson({}), // No content-length header | ||
| null, // requestPostData not used for this test | ||
| null, // responseContent not used for this test | ||
| ); | ||
|
|
||
| expect(request.responseBytes, null); | ||
| }); | ||
|
|
||
| // Returns null when parsing fails. | ||
| test('returns null for invalid value', () { | ||
| final request = DartIOHttpRequestData.fromJson( | ||
| baseJson({'content-length': 'invalid'}), | ||
| null, // requestPostData not used for this test | ||
| null, // responseContent not used for this test | ||
| ); | ||
|
|
||
| expect(request.responseBytes, null); | ||
| }); | ||
| }); | ||
| } |
19 changes: 19 additions & 0 deletions
19
packages/devtools_app/test/shared/http/http_utils_test.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import 'package:devtools_app/src/screens/network/utils/http_utils.dart'; | ||
| import 'package:flutter_test/flutter_test.dart'; | ||
|
|
||
| void main() { | ||
| group('formatBytes', () { | ||
| // Verifies correct formatting across different unit ranges. | ||
| test('formats bytes correctly', () { | ||
| expect(formatBytes(512), '512 B'); // bytes | ||
| expect(formatBytes(2000), '2.0 kB'); // kilobytes (base-10) | ||
| expect(formatBytes(1000000), '1.0 MB'); // megabytes (base-10) | ||
| }); | ||
|
|
||
| // Ensures handling of invalid or missing values. | ||
| test('handles null and negative values', () { | ||
| expect(formatBytes(null), '-'); | ||
| expect(formatBytes(-1), '-'); | ||
| }); | ||
| }); | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.