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

Implement a utility class to save large downloads to a file #929

Closed
sbordet opened this issue Sep 14, 2016 · 9 comments
Closed

Implement a utility class to save large downloads to a file #929

sbordet opened this issue Sep 14, 2016 · 9 comments
Labels
Enhancement Help Wanted Pinned Issues that never go stale

Comments

@sbordet
Copy link
Contributor

sbordet commented Sep 14, 2016

HttpClient could benefit of a utility class that saves the download bytes to a file, akin to:

curl <url> -o file.bin

Perhaps call it PathResponseListener.

Beware that FileChannel.write(ByteBuffer) returns the number of bytes written, that can be less than the bytes in the buffer, see also #630.

@stale
Copy link

stale bot commented Nov 20, 2019

This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Stale For auto-closed stale issues and pull requests label Nov 20, 2019
@sbordet
Copy link
Contributor Author

sbordet commented Nov 21, 2019

Would still be nice to have.

@stale stale bot removed the Stale For auto-closed stale issues and pull requests label Nov 21, 2019
@stale
Copy link

stale bot commented Nov 21, 2020

This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Stale For auto-closed stale issues and pull requests label Nov 21, 2020
@sbordet sbordet removed the Stale For auto-closed stale issues and pull requests label Nov 21, 2020
@github-actions
Copy link

This issue has been automatically marked as stale because it has been a
full year without activity. It will be closed if no further activity occurs.
Thank you for your contributions.

@github-actions github-actions bot added the Stale For auto-closed stale issues and pull requests label May 18, 2022
@sbordet sbordet removed the Stale For auto-closed stale issues and pull requests label May 18, 2022
@github-actions
Copy link

This issue has been automatically marked as stale because it has been a
full year without activity. It will be closed if no further activity occurs.
Thank you for your contributions.

@github-actions github-actions bot added the Stale For auto-closed stale issues and pull requests label May 19, 2023
@sbordet sbordet removed the Stale For auto-closed stale issues and pull requests label May 19, 2023
Copy link

This issue has been automatically marked as stale because it has been a
full year without activity. It will be closed if no further activity occurs.
Thank you for your contributions.

@github-actions github-actions bot added the Stale For auto-closed stale issues and pull requests label May 19, 2024
@sbordet sbordet added Pinned Issues that never go stale and removed Stale For auto-closed stale issues and pull requests labels May 19, 2024
@sbordet
Copy link
Contributor Author

sbordet commented Sep 3, 2024

@arsenalzp are you interested in implementing this one?

@arsenalzp
Copy link
Contributor

@arsenalzp are you interested in implementing this one?

Hello,
Let's manage with it!

@sbordet
Copy link
Contributor Author

sbordet commented Sep 3, 2024

@arsenalzp this is how I would like to use it:

// Async mode.
httpClient.newRequest(host, port)
  .send(new PathResponseListener(Path.of("/tmp/file.bin"));

// CompletableFuture mode.
var request = httpClient.newRequest(host, port);
CompletableFuture<Path> completable = PathResponseListener.write(request, Path.of("/tmp/file.bin"));

PathResponseListener should implement CompleteListener and one of the content listeners, perhaps ContentListener is enough.

Start with simple test cases: a test that writes 0 bytes, one that writes 1 MiB and one that writes more than 1 GiB.
Make sure at the end of the test the files are deleted.
Then write test cases for failures: for example a Path that does not exist, a Path that exist but it is not writable, a download that is interrupted by the server (the server writes some content, then closes the connection), etc.

Let me know if you need more guidance.

@sbordet sbordet moved this to 🏗 In progress in Jetty 12.0.14 Sep 27, 2024
sbordet added a commit that referenced this issue Sep 27, 2024
…ile.

* PathResponseListener now yields a PathResponse record with Path and Response.
* Code cleanups.
* Simplified test cases.
* Added documentation.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in Jetty 12.0.14 Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Help Wanted Pinned Issues that never go stale
Projects
No open projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

2 participants