Fix range response

The range starts from zero, so we are returning one byte too many.
Docker echos this back to us in the manifest it uploads which is where
the extra byte is coming from.

This is actually the root cause of the off-by-one error worked around
in 134c942835.  A follow-on will clean
this up (Ibe061171bfd8ab6043b491bbab933bf277f8e12b).

Change-Id: I1fb1abf3c76ea8db7820caa90c97ddbf92997842
This commit is contained in:
Ian Wienand 2021-09-13 13:08:02 +10:00 committed by Clark Boylan
parent 7100c360b3
commit ce2fb31a72

View File

@ -271,7 +271,8 @@ class RegistryAPI:
orig_repository, uuid) orig_repository, uuid)
res.headers['Docker-Upload-UUID'] = uuid res.headers['Docker-Upload-UUID'] = uuid
res.headers['Content-Length'] = '0' res.headers['Content-Length'] = '0'
res.headers['Range'] = '0-%s' % (new_length,) # Be careful to not be off-by-one, range starts at 0
res.headers['Range'] = '0-%s' % (new_length - 1,)
res.status = '202 Accepted' res.status = '202 Accepted'
self.log.info( self.log.info(
'[u: %s] Finish Upload chunk %s %s', uuid, repository, new_length) '[u: %s] Finish Upload chunk %s %s', uuid, repository, new_length)