--- id: http-save_to name: Http.save_to category: http kind: namespace-method tokens: Http.save_to sig: Http.save_to(handle, path) -> void tip: Stream the response body to a file. order: 16 ns: Http member: save_to --- Makes the response body of an Http.opened request go straight to the file at path as it arrives, instead of into memory — the way to download something large (an update package of hundreds of megabytes) with a progress bar. Call it before Http.send; afterwards it does nothing. The file is written directly at path, with no temporary name: Http.send creates it (or truncates an existing one), and a failed or cancelled download leaves whatever had arrived. So download to a name of your own such as "x.nupkg.part" and rename it once Http.poll reports a good status — a non-2xx reply's body (an error page) is written to the file too. If the file cannot be created the request finishes with status 0, as does one whose write fails midway (a full disk). For such a request Http.text is empty (null) and Http.body_len is the number of bytes written. Follow progress with Http.received and Http.expected. Freeing the request while it is pending cancels the download. The transfer asks for no compression (Accept-Encoding: identity) unless the request set that header, so the bytes counted are the bytes on disk. Files are limited to 2 GB. ```ludic program Demo { entry { let h = Http.open("GET", "https://example.com/big.bin") Http.save_to(h, "big.bin.part") Http.send(h) } } ```