Skip to content

Commit 1ce6c9d

Browse files
committed
Fix: bad request will remove header and retry login
If AWS ECR returns a bad request on /v2/ with basic auth and provides no www-authenticate information. Retry the request after removing the Authorization header. Signed-off-by: ChengHao Yang <17496418+tico88612@users.noreply.github.com>
1 parent 4a8f945 commit 1ce6c9d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Sources/ContainerizationOCI/Client/RegistryClient.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,12 @@ public final class RegistryClient: ContentClient {
205205

206206
continue
207207
}
208+
else if _response.status == .badRequest && request.headers.contains(name: "Authorization") {
209+
// Retry without basic auth
210+
request.headers.remove(name: "Authorization")
211+
retryCount += 1
212+
continue
213+
}
208214
guard let retryOptions = self.retryOptions else {
209215
break
210216
}

0 commit comments

Comments
 (0)