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

JavaClient stream response body using byte arrays #1007

Conversation

alex-james-dev
Copy link
Contributor

@alex-james-dev alex-james-dev commented Aug 18, 2023

  • Currently, JavaClient streams the HTTP response body one byte at a time; this is slow. Make JavaClient stream the HTTP response body using byte arrays; this is faster. Each byte array can contain up to 4096 bytes.

  • If none of the HTTP response body bytes are available without blocking, let the worker isolate's event loop run.

  • Generate bindings for java.io.BufferedInputStream using jnigen.

  • Create a BufferedInputStream from the HTTP response body InputStream to improve performance.

Context

This is a PR for the java_http GSoC '23 project 🌞.
Relevant tracking issue: #957.


  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.
Contribution guidelines:

Note that many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.

@alex-james-dev alex-james-dev changed the title Make JavaClient stream response body using byte arrays JavaClient stream response body using byte arrays Aug 22, 2023
@alex-james-dev
Copy link
Contributor Author

I renamed the PR title to be <= 50 characters 😄

@alex-james-dev
Copy link
Contributor Author

I've done a bit of refactoring to try to clean the code up a bit:

  • Renamed some variables.

  • Rewrote the while loop condition so that it fits on one line.

  • Created an extension method for converting from JArray<jbyte> to Uint8List.

The PR is now ready for review! 🎉

Thank you!

@alex-james-dev alex-james-dev marked this pull request as ready for review August 22, 2023 23:57
@brianquinlan brianquinlan merged commit 5ac7cfe into dart-lang:master Aug 24, 2023
15 checks passed
@alex-james-dev alex-james-dev deleted the java-http-stream-response-body-with-byte-arrays branch August 24, 2023 17:41
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