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

Open
sbordet opened this issue Sep 14, 2016 · 9 comments · May be fixed by #12292
Open

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

sbordet opened this issue Sep 14, 2016 · 9 comments · May be fixed by #12292
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

@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.

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
None yet
Development

Successfully merging a pull request may close this issue.

2 participants