Add an additional short circuit to avoid parsing the manifest when not necessary for older Docker clients
We also add tests for this case
This commit is contained in:
parent
7f068c3fc3
commit
e78b5c5516
3 changed files with 36 additions and 4 deletions
|
@ -208,7 +208,7 @@ class V2Protocol(RegistryProtocol):
|
|||
|
||||
headers = {
|
||||
'Authorization': 'Bearer ' + token,
|
||||
'Accept': ','.join(options.accept_mimetypes) if options.accept_mimetypes else '*/*',
|
||||
'Accept': ','.join(options.accept_mimetypes) if options.accept_mimetypes is not None else '*/*',
|
||||
}
|
||||
|
||||
# Push all blobs.
|
||||
|
@ -340,7 +340,7 @@ class V2Protocol(RegistryProtocol):
|
|||
|
||||
headers = {
|
||||
'Authorization': 'Bearer ' + token,
|
||||
'Accept': ','.join(options.accept_mimetypes) if options.accept_mimetypes else '*/*',
|
||||
'Accept': ','.join(options.accept_mimetypes) if options.accept_mimetypes is not None else '*/*',
|
||||
}
|
||||
|
||||
# Build fake manifests.
|
||||
|
@ -530,7 +530,9 @@ class V2Protocol(RegistryProtocol):
|
|||
}
|
||||
|
||||
if self.schema2:
|
||||
headers['Accept'] = ','.join(options.accept_mimetypes or DOCKER_SCHEMA2_CONTENT_TYPES)
|
||||
headers['Accept'] = ','.join(options.accept_mimetypes
|
||||
if options.accept_mimetypes is not None
|
||||
else DOCKER_SCHEMA2_CONTENT_TYPES)
|
||||
|
||||
manifests = {}
|
||||
image_ids = {}
|
||||
|
|
|
@ -1854,3 +1854,27 @@ def test_push_pull_emoji_unicode_direct(pusher, puller, unicode_emoji_images, li
|
|||
# Pull the repository to verify.
|
||||
puller.pull(liveserver_session, 'devtable', 'newrepo', 'latest', unicode_emoji_images,
|
||||
credentials=credentials, options=options)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('accepted_mimetypes', [
|
||||
[],
|
||||
['application/json'],
|
||||
])
|
||||
def test_push_pull_older_mimetype(pusher, puller, basic_images, liveserver_session, app_reloader,
|
||||
accepted_mimetypes):
|
||||
""" Test: Push and pull an image, but override the accepted mimetypes to that sent by older
|
||||
Docker clients.
|
||||
"""
|
||||
credentials = ('devtable', 'password')
|
||||
|
||||
# Push a new repository.
|
||||
pusher.push(liveserver_session, 'devtable', 'newrepo', 'latest', basic_images,
|
||||
credentials=credentials)
|
||||
|
||||
# Turn off automatic unicode encoding when building the manifests.
|
||||
options = ProtocolOptions()
|
||||
options.accept_mimetypes = accepted_mimetypes
|
||||
|
||||
# Pull the repository to verify.
|
||||
puller.pull(liveserver_session, 'devtable', 'newrepo', 'latest', basic_images,
|
||||
credentials=credentials, options=options)
|
||||
|
|
Reference in a new issue