diff --git a/endpoints/v2/blob.py b/endpoints/v2/blob.py index 58598f464..919c4dd16 100644 --- a/endpoints/v2/blob.py +++ b/endpoints/v2/blob.py @@ -38,7 +38,6 @@ def _base_blob_fetch(namespace, repo_name, digest): headers = { 'Docker-Content-Digest': digest, - 'Content-Length': found.image_size, } # Add the Accept-Ranges header if the storage engine supports resumable @@ -56,11 +55,11 @@ def _base_blob_fetch(namespace, repo_name, digest): @anon_protect @cache_control(max_age=31436000) def check_blob_exists(namespace, repo_name, digest): - _, headers = _base_blob_fetch(namespace, repo_name, digest) + found, headers = _base_blob_fetch(namespace, repo_name, digest) response = make_response('') response.headers.extend(headers) - response.headers['Content-Length'] = headers['Content-Length'] + response.headers['Content-Length'] = found.image_size return response @@ -87,6 +86,8 @@ def download_blob(namespace, repo_name, digest): # Close the database handle here for this process before we send the long download. database.close_db_filter(None) + headers['Content-Length'] = found.image_size + return Response(storage.stream_read(found.locations, path), headers=headers)