Skip to content

Commit bdb9cdb

Browse files
authored
ContainerRegistry: Tolerate missing Content-Type header in registry response (#26)
### Motivation ECR does not set the `Content-Type` header in its response to a blob upload. If it is not present, the HTTP standard allows clients to guess the content type, or default to `application/octet-stream'. In this case, knowing the content type is not critical so there is no need to check for it. ### Modifications Do not check that responses contain the `Content-Type` header in the low-level HTTP client. ### Result Blob uploads to ECR will not fail. ### Test Plan Automated tests continue to pass; tested manually with ECR.
1 parent bb85677 commit bdb9cdb

File tree

1 file changed

+0
-6
lines changed

1 file changed

+0
-6
lines changed

Sources/ContainerRegistry/HTTPClient.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,6 @@ extension URLSession: HTTPClient {
8181
}
8282
}
8383

84-
// Content-Type should always be set, but there may be registries which don't set it. If it is not present, the HTTP standard allows
85-
// clients to guess the content type, or default to `application/octet-stream'.
86-
guard let _ = response.headerFields[.contentType] else {
87-
throw HTTPClientError.missingResponseHeader("Content-Type")
88-
}
89-
9084
// A HEAD request has no response body and cannot be decoded
9185
if request.method == .head {
9286
throw HTTPClientError.unexpectedStatusCode(status: response.status, response: response, data: nil)

0 commit comments

Comments
 (0)