Repository navigation
Download control: several connections, file names, headers and retries - #18
Merged
Merged
Conversation
download takes an optional connections: int. The first connection asks for the whole file as a range; when the server answers 206 with the file's size, the file is split into parts of at least 64 KB, each fetched by its own connection into its own place in the .part file, opening the file separately. A server that sends all of it, or no size, keeps one connection. Each outlet now has room for its part's end, pausing records how far each part got, and resuming opens a connection for each unfinished part. Adds connections to DownloadDesc and bumps ABI_VERSION to 5.
download takes an optional name: string. It goes through the same sanitising as a name from the address, so it can't leave the folder, then Partial::create, so it keeps the no-overwrite numbering. "", the default, names the file after the address. Adds name to DownloadDesc, within ABI 5.
download takes optional headers: [string], each written Name: value, sent with every request through http::get; a malformed header or Range fails the download before it asks the server. retries: int tries a connection again after a failure that may pass (a broken-off body, a connect timeout or a 5xx), waiting 1 s, doubling to 30 s. The wait is spent in recv_timeout on the event receiver, so pausing or cancelling still works at once; status says Retrying… while every unfinished part waits. Download hold()s each borrowed setting across all later expressions, not just the next. Adds headers and retries to DownloadDesc, within ABI 5, and moves download control to Supported on the roadmap.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Finishes download control after #17. There are three new optional settings on
download, one commit each.What's new
connections: int(244a3fa) — the first connection asks forRange: bytes=0-. When the server answers206with the file's size, the file is split into parts of at least 64 KiB, with at most 16 connections. Each part is fetched by its own connection into its own place in the.partfile, and each connection opens the file separately. Each outlet has room for its part's end. Pausing records how far each part got, and resuming opens a connection for each unfinished part. A200answer, or one with no size, keeps one connection.name: string(9fb959d) — this goes through the same sanitising as a name from the address (nowname::safe_file_name), thenPartial::create, so it can't leave the folder and never overwrites a file."", the default, names the file after the address.headers: [string]andretries: int(993b2d8) — each header is writtenName: valueand sent on every request throughhttp::get. A malformed header, orRange, fails the download before it asks the server anything. Retries only cover transient errors: a broken body read, a connect timeout, or a 5xx. The wait starts at 1 s and doubles up to 30 s, usingrecv_timeouton the event receiver so pause and cancel still work during it. While every unfinished part is waiting,statusshowsRetrying….Every surface
DownloadDescgainsname,connections,headersandretries, andABI_VERSIONgoes from 4 to 5 (bumped once for all three).downloadnow holds each borrowed setting across all later expressions, not just the next one (newhold_across).functions.md, cheat sheet, syntax decisions 25–28 inlanguage.md, and the roadmap (download control moves to Supported).downloader.nffixture gains a Connections slider,retries: 3, andRetrying…inis_running.Tests
All tests run against the local test server and are deterministic, with no sleeps. The test server now supports closed ranges,
bytes=a-b.make checkpasses, including clippy forx86_64-pc-windows-msvc. The two retry tests wait out the real 1 s backoff.Checked by hand
.partfile open (Windows file locking)No backend code changed.
Follow-up
Body::dialogin codegen has the same gap the download had: each borrowed argument is held only across the next expression.hold_acrosscovers the fix; I've left it out of this PR.