File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
common/src/main/kotlin/com/lambda/network Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -35,13 +35,17 @@ val LambdaHttp = HttpClient {
3535}
3636
3737suspend inline fun HttpClient.download (url : String , file : File , block : HttpRequestBuilder .() -> Unit = {}) {
38- val response = get(url, block).readRawBytes()
39- file.writeBytes(response)
38+ val response = get(url, block)
39+ check(response.status.isSuccess()) { " Download for $url failed with non 2xx status code" }
40+
41+ file.writeBytes(response.readRawBytes())
4042}
4143
4244suspend inline fun HttpClient.download (url : String , output : OutputStream , block : HttpRequestBuilder .() -> Unit = {}) {
43- val response = get(url, block).readRawBytes()
44- output.write(response)
45+ val response = get(url, block)
46+ check(response.status.isSuccess()) { " Download for $url failed with non 2xx status code" }
47+
48+ output.write(response.readRawBytes())
4549}
4650
4751suspend inline fun HttpClient.download (url : String , block : HttpRequestBuilder .() -> Unit ) =
You can’t perform that action at this time.
0 commit comments