Skip to content

Commit de075ff

Browse files
authored
Fix: bad request will remove header and retry login (apple#711)
If you're requesting on `/v2/` with basic auth, AWS ECR will return 400 Bad Request and won't provide `www-authenticate` information. Retry the request after removing the Authorization header. Continue PR apple#429 Fixed apple/container#847 Signed-off-by: ChengHao Yang <17496418+tico88612@users.noreply.github.com>
1 parent b62edd2 commit de075ff

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

Sources/ContainerizationOCI/Client/RegistryClient.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,11 @@ public final class RegistryClient: ContentClient {
210210
throw err
211211
}
212212

213+
continue
214+
} else if _response.status == .badRequest && request.headers.contains(name: "Authorization") {
215+
// Retry without basic auth
216+
request.headers.remove(name: "Authorization")
217+
retryCount += 1
213218
continue
214219
}
215220
guard let retryOptions = self.retryOptions else {

0 commit comments

Comments
 (0)