Always use absolute URLs in Location headers.

This works around docker/docker#15048
This commit is contained in:
Jake Moshenko 2016-10-07 15:41:35 -04:00
parent 343d293001
commit df1f35e9f9
2 changed files with 23 additions and 13 deletions

View file

@ -29,7 +29,7 @@ from jwkest.jwk import RSAKey
import endpoints.decorated # required for side effect
from app import app, storage, instance_keys
from app import app, storage, instance_keys, get_app_url
from data.database import close_db_filter, configure, DerivedStorageForImage, QueueItem, Image
from data import model
from digest.checksums import compute_simple
@ -603,7 +603,14 @@ class V2RegistryPushMixin(V2RegistryMixin):
expected_code=202, auth='jwt')
upload_uuid = response.headers['Docker-Upload-UUID']
location = response.headers['Location'][len(self.get_server_url()):]
server_hostname = get_app_url()
new_upload_location = response.headers['Location']
self.assertTrue(new_upload_location.startswith(server_hostname))
# We need to make this relative just for the tests because the live server test
# case modifies the port.
location = response.headers['Location'][len(server_hostname):]
# PATCH the image data into the layer.
if chunks is None: