Skip to content

Commit 69b9e99

Browse files
committed
ContainerRegistry: A /v2/ protocol check response is allowed to be empty
1 parent 714952e commit 69b9e99

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Sources/ContainerRegistry/CheckAPI.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@ public extension RegistryClient {
1616
/// Returns a boolean value indicating whether the registry supports v2 of the distribution specification.
1717
/// - Returns: `true` if the registry supports the distribution specification, otherwise `false`.
1818
func checkAPI() async throws -> Bool {
19-
// The registry indicates that it supports the v2 protocol by returning an empty JSON object i.e. {}.
20-
// The registry may require authentication on this endpoint.
2119
// See https://github.com/opencontainers/distribution-spec/blob/main/spec.md#determining-support
20+
// The registry indicates that it supports the v2 protocol by returning a 200 OK response.
21+
// Many registries also set `Content-Type: application/json` and return empty JSON objects,
22+
// but this is not required and some do not.
23+
// The registry may require authentication on this endpoint.
2224
do {
23-
return try await executeRequestThrowing(
25+
let _ = try await executeRequestThrowing(
2426
.get(registryURLForPath("/v2/")),
2527
decodingErrors: [.unauthorized, .notFound]
2628
)
27-
.data == EmptyObject()
29+
return true
2830
} catch HTTPClientError.unexpectedStatusCode(status: .notFound, _, _) { return false }
2931
}
3032
}

0 commit comments

Comments
 (0)