scoop:scoop.http.client:0.1.0
src/download/api.scoop
Selected production source · src/download/api.scoop
1
package scoop.http.client3
import scoop.http.HttpField4
import scoop.http.HttpResponseHead5
import scoop.platform.fs.Path6
import scoop.url.Url8
/**9
* Download publication, buffering, and progress policy. Completion atomically installs the10
* destination; failures retain the prior destination.11
*/12
public class HttpDownloadOptions internal constructor(13
/**14
* Whether atomic publication may replace an existing destination.15
*/16
public val replaceExisting: Boolean = false,17
/**18
* Whether file contents are synchronized before the final commit.19
*/20
public val syncOnCommit: Boolean = false,21
/**22
* The positive byte-buffer size used while streaming to disk.23
*/24
public val bufferSize: Long = 8192L,25
/**26
* Suspend callback for written-byte progress; it participates in cancellation and failure27
* cleanup.28
*/29
public val onProgress: suspend (HttpDownloadProgress) -> Unit = suspend { _ -> }30
) {31
init {32
if (bufferSize <= 0L)33
throw IllegalArgumentException(Some("download buffer size must be positive"))34
}35
}37
/**38
* A download progress snapshot with current written bytes, known total, and any reused prefix.39
*/40
public class HttpDownloadProgress internal constructor(41
/**42
* The final response URL.43
*/44
public val url: Url,45
/**46
* Total bytes present in the download so far, including any reused prefix.47
*/48
public val bytesWritten: Long,49
/**50
* The expected complete size when known.51
*/52
public val totalBytes: Long?,53
/**54
* Bytes retained from a previously validated partial file.55
*/56
public val resumedBytes: Long = 0L57
)59
/**60
* A completed download with committed path, final response metadata, total bytes, and61
* reused-prefix count.62
*/63
public class HttpDownloadResult internal constructor(64
/**65
* The committed destination path.66
*/67
public val path: Path,68
/**69
* The final response URL.70
*/71
public val url: Url,72
/**73
* The successful final response head.74
*/75
public val head: HttpResponseHead,76
/**77
* Complete response trailers after body consumption.78
*/79
public val trailers: Array<HttpField>,80
/**81
* The complete committed file byte count.82
*/83
public val byteCount: Long,84
/**85
* Bytes reused from the previous partial download.86
*/87
public val resumedBytes: Long = 0L88
)