Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion Sources/ContainerClient/FileDownloader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,23 @@ public struct FileDownloader {
})

let client = FileDownloader.createClient(url: url)
_ = try await client.execute(request: request, delegate: delegate).get()
do {
_ = try await client.execute(request: request, delegate: delegate).get()
} catch {
try? await client.shutdown()
throw error
}
try await client.shutdown()
}

private static func createClient(url: URL) -> HTTPClient {
var httpConfiguration = HTTPClient.Configuration()
// for large file downloads we keep a generous connect timeout, and
// no read timeout since download durations can vary
httpConfiguration.timeout = HTTPClient.Configuration.Timeout(
connect: .seconds(30),
read: .none
)
if let host = url.host {
let proxyURL = ProxyUtils.proxyFromEnvironment(scheme: url.scheme, host: host)
if let proxyURL, let proxyHost = proxyURL.host {
Expand Down