Skip to content
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

[package:http_profile] Store request and response bodies in the backing map as lists instead of as streams #1154

Merged
merged 1 commit into from
Mar 8, 2024

Conversation

derekxu16
Copy link
Member

This PR also adds getters that return the request and response bodies as lists of ints

@derekxu16 derekxu16 requested a review from brianquinlan March 8, 2024 16:20
@derekxu16 derekxu16 changed the title Store request and response bodies in the backing map as lists instead of as streams [package:http_profile] Store request and response bodies in the backing map as lists instead of as streams Mar 8, 2024
… of streams

This PR also adds getters that return the request and response bodies as lists of ints
unawaited(bodySink.close());
_data['endTime'] = (endTime ?? DateTime.now()).microsecondsSinceEpoch;
await bodySink.close();
_responseData['endTime'] =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this was incorrect before?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It worked before because we were awaiting _body.stream.expand(...).toList(...) on the SDK side, so it was impossible for this unawaited bodySink.close() to cause the 'requestBody' or 'responseBody' entries to get populated incorrectly here (https://github.com/dart-lang/sdk/blob/9efa95674966c1d8b498c1846372f36db689f8c7/sdk/lib/io/network_profiling.dart#L34-L44).

With the changes in this PR, we need to await bodySink.close() to guarantee that all the bytes that have been added to the sink have also been added to _data['requestBodyBytes'] before the SDK tries to read _data['requestBodyBytes'].

requestData._body.stream.listen(
(final bytes) => (_data['requestBodyBytes'] as List<int>).addAll(bytes),
);

@derekxu16 derekxu16 merged commit 8da6e0e into dart-lang:master Mar 8, 2024
28 checks passed
@derekxu16 derekxu16 deleted the body-getters branch March 8, 2024 20:20
copybara-service bot pushed a commit to dart-lang/sdk that referenced this pull request Mar 11, 2024
Revisions updated by `dart tools/rev_sdk_deps.dart`.

async (https://github.com/dart-lang/async/compare/6cdbc41..1556660):
  1556660  2024-03-07  Kevin Moore  Test on wasm (dev) and JS (dart-archive/async#269)

dartdoc (https://github.com/dart-lang/dartdoc/compare/0de8aff..ef990e7):
  ef990e79  2024-03-10  dependabot[bot]  Bump actions/cache from 4.0.0 to 4.0.1 (dart-lang/dartdoc#3700)
  962d68fe  2024-03-08  Sam Rawlins  Convert many fields on Container and TopLevelContainer to getters (dart-lang/dartdoc#3710)
  353b426c  2024-03-08  Kallen Tu  Remove unresolved-export warning. (dart-lang/dartdoc#3711)
  cdcbf6d8  2024-03-08  Kallen Tu  Change mixin implements and remove unused Extendable. (dart-lang/dartdoc#3709)
  da7071d5  2024-03-08  Sam Rawlins  Display an extension's extended type in a few places. (dart-lang/dartdoc#3708)
  3d56168d  2024-03-08  Sam Rawlins  Add some help messages to tool/task.dart (dart-lang/dartdoc#3707)
  4f849678  2024-03-07  Sam Rawlins  Remove the TypeImplementing mixin; unnecessary (dart-lang/dartdoc#3705)
  7b50ea4a  2024-03-07  Sam Rawlins  Move the `filterNonDocumented` and `filterNonPublic` functions as extension getters (dart-lang/dartdoc#3699)

http (https://github.com/dart-lang/http/compare/8d3c647..8da6e0e):
  8da6e0e  2024-03-08  Derek Xu  [package:http_profile] Store request and response bodies in the backing map as lists instead of streams (dart-lang/http#1154)

markdown (https://github.com/dart-lang/markdown/compare/1ca5166..9c6b1af):
  9c6b1af  2024-03-10  Jonas Finnemann Jensen  Run a periodic crash-test (dart-lang/markdown#590)
  1654801  2024-03-08  Zhiguang Chen  Add single tilde support to `StrikethroughSyntax` (dart-lang/markdown#595)

test (https://github.com/dart-lang/test/compare/7724aab..ba64bbb):
  ba64bbba  2024-03-07  Nate Bosch  Let the IsolateChannel close the ReceivePort (dart-lang/test#2196)

Change-Id: I5fad5442fe1a183707888276264eb9c47cc3c96f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/356780
Commit-Queue: Konstantin Shcheglov <[email protected]>
Auto-Submit: Devon Carew <[email protected]>
Reviewed-by: Konstantin Shcheglov <[email protected]>
Commit-Queue: Devon Carew <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants