@@ -33,25 +33,26 @@ public final class RegistryManager {
33
33
return ZipArchiver ( fileSystem: fileSystem)
34
34
}
35
35
36
- internal static var clientFactory : ( ) -> HTTPClientProtocol = {
36
+ internal static var clientFactory : ( DiagnosticsEngine ? ) -> HTTPClientProtocol = { diagnosticEngine in
37
37
var configuration = HTTPClientConfiguration ( )
38
38
configuration. followRedirects = false
39
39
40
- return HTTPClient ( configuration: configuration, handler: nil , diagnosticsEngine: nil )
40
+ return HTTPClient ( configuration: configuration, handler: nil , diagnosticsEngine: diagnosticEngine )
41
41
}
42
42
43
43
private static var cache = ThreadSafeKeyValueStore < URL , RegistryManager > ( )
44
44
45
45
private let registryBaseURL : Foundation . URL
46
46
private let client : HTTPClientProtocol
47
47
48
- init ( registryBaseURL: Foundation . URL ) {
48
+ init ( registryBaseURL: Foundation . URL , diagnosticEngine : DiagnosticsEngine ? = nil ) {
49
49
self . registryBaseURL = registryBaseURL
50
- client = Self . clientFactory ( )
50
+ self . client = Self . clientFactory ( diagnosticEngine )
51
51
}
52
52
53
53
public class func discover(
54
54
for package : PackageReference ,
55
+ diagnosticsEngine: DiagnosticsEngine ? = nil ,
55
56
on queue: DispatchQueue ,
56
57
completion: @escaping ( Result < RegistryManager , Error > ) -> Void
57
58
) {
@@ -71,15 +72,15 @@ public final class RegistryManager {
71
72
]
72
73
)
73
74
74
- let client = clientFactory ( )
75
+ let client = clientFactory ( diagnosticsEngine )
75
76
76
77
let response = try tsc_await { client. execute ( request, callback: $0) }
77
78
if response. statusCode == 303 ,
78
79
response. headers. get ( " Content-Version " ) . first == " 1 " ,
79
80
let location = response. headers. get ( " Location " ) . first,
80
81
let redirectedURL = URL ( string: location, relativeTo: url)
81
82
{
82
- return RegistryManager ( registryBaseURL: redirectedURL)
83
+ return RegistryManager ( registryBaseURL: redirectedURL, diagnosticEngine : diagnosticsEngine )
83
84
} else {
84
85
throw RegistryError . invalidResponse
85
86
}
@@ -199,7 +200,6 @@ public final class RegistryManager {
199
200
]
200
201
)
201
202
202
- let client = Self . clientFactory ( )
203
203
client. execute ( request) { result in
204
204
switch result {
205
205
case . success( let response) :
0 commit comments