Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Treatment download

http/client::download


Parameters

↳ var retries: u32 = 5

Inputs

⇥ request: Block<PreparedRequest> (http/client::PreparedRequest)

Outputs

↦ completed: Block<void>
↦ data: Stream<byte>
↦ error: Block<string>
↦ failed: Block<void>
↦ finished: Block<void>


Download what a prepared request gives, resuming after cuts.

The body of the answer to request, such as a presigned download of object storage, is streamed through data. When the download is cut (connection lost, 5xx, 429 or 408 answer), it resumes up to retries times, waiting longer each time, from where it was cut (Range), on the same version of the object (If-Match with the ETag of the first answer): no byte is given twice.

Once the whole object is given, completed is emitted. If the request is refused, the object changes, it cannot be resumed (no ETag), or retries are exhausted, failed is emitted and error contains the reason, with the status and the <Code> of XML error bodies, never the URL. What was given before does not make the whole object then. finished is emitted in every case.

The request is made as given, without the headers of any HttpClient.

graph LR
     T("download()")
     R["〈🟨〉"] -->|request| T

     T -->|data| O["… 🟦 🟦 🟦"]
     T -->|completed| C["〈🟩〉"]
     T -->|failed| F["〈🟥〉"]

     style R fill:#ffffff,stroke:#ffffff
     style O fill:#ffffff,stroke:#ffffff
     style C fill:#ffffff,stroke:#ffffff
     style F fill:#ffffff,stroke:#ffffff