Skip to content
Open
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 @@ -6,6 +6,7 @@ import 'dart:convert';
import 'dart:typed_data';

import '../../screens/network/utils/http_utils.dart';
import '../../shared/http/constants.dart' as shared_http;
import '../../shared/http/http_request_data.dart';
import 'constants.dart';

Expand Down Expand Up @@ -45,6 +46,15 @@ class HarDataEntry {
final requestPostData = responseData[NetworkEventKeys.postData.name];
final responseContent = responseData[NetworkEventKeys.content.name];

final statusValue = responseData[NetworkEventKeys.status.name];
final statusCode = switch (statusValue) {
int() => statusValue,
String() => int.tryParse(statusValue),
_ => null,
};
responseData[shared_http.HttpRequestDataKeys.statusCode.name] =
statusCode ?? -1;

return HarDataEntry(
DartIOHttpRequestData.fromJson(
modifiedRequestData,
Expand Down Expand Up @@ -148,7 +158,7 @@ class HarDataEntry {
},
// Response
NetworkEventKeys.response.name: <String, Object?>{
NetworkEventKeys.status.name: e.status,
NetworkEventKeys.status.name: int.tryParse(e.status ?? '') ?? -1,
NetworkEventKeys.statusText.name:
e.general[NetworkEventKeys.reasonPhrase.name] ?? '',
NetworkEventKeys.httpVersion.name:
Expand Down
3 changes: 2 additions & 1 deletion packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ TODO: Remove this section if there are not any updates.

## Network profiler updates

TODO: Remove this section if there are not any updates.
- Fixed exported response status in HAR files so that they parse as integers
instead of strings. [#9900](https://github.com/flutter/devtools/pull/9900)

## Logging updates

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ void main() {
expect(harDataEntry.request.method, 'GET');
expect(harDataEntry.request.requestHeaders, isNotEmpty);
expect(harDataEntry.request.requestCookies, isEmpty);
expect(harDataEntry.request.status, '200');
});

test('toJson serializes correctly', () {
Expand All @@ -89,6 +90,11 @@ void main() {
expect(request?['cookies'], isEmpty);

expect(json['cache'], isEmpty);
final response = json['response'] as Map<String, Object?>?;
expect(response, isNotNull);
expect(response?['status'], 200);
expect(response?['statusText'], '');

final timings = json['timings'] as Map<String, Object?>?;
expect(timings?['blocked'], NetworkEventDefaults.blocked);
expect(timings?['dns'], NetworkEventDefaults.dns);
Expand Down
Loading