Merge "Do not loose url queries on redirects"
This commit is contained in:
commit
befcca345b
|
@ -105,18 +105,26 @@ class StoreLocation(glance_store.location.StoreLocation):
|
||||||
self.user = self.specs.get('user')
|
self.user = self.specs.get('user')
|
||||||
self.password = self.specs.get('password')
|
self.password = self.specs.get('password')
|
||||||
self.path = self.specs.get('path')
|
self.path = self.specs.get('path')
|
||||||
|
self.query = self.spec.get('query')
|
||||||
|
|
||||||
def _get_credstring(self):
|
def _get_credstring(self):
|
||||||
if self.user:
|
if self.user:
|
||||||
return '%s:%s@' % (self.user, self.password)
|
return '%s:%s@' % (self.user, self.password)
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
def _get_query_string(self):
|
||||||
|
if self.query:
|
||||||
|
return "?%s" % self.query
|
||||||
|
return ""
|
||||||
|
|
||||||
def get_uri(self):
|
def get_uri(self):
|
||||||
return "%s://%s%s%s" % (
|
return "%s://%s%s%s%s" % (
|
||||||
self.scheme,
|
self.scheme,
|
||||||
self._get_credstring(),
|
self._get_credstring(),
|
||||||
self.netloc,
|
self.netloc,
|
||||||
self.path)
|
self.path,
|
||||||
|
self._get_query_string()
|
||||||
|
)
|
||||||
|
|
||||||
def parse_uri(self, uri):
|
def parse_uri(self, uri):
|
||||||
"""
|
"""
|
||||||
|
@ -164,6 +172,7 @@ class StoreLocation(glance_store.location.StoreLocation):
|
||||||
|
|
||||||
self.netloc = netloc
|
self.netloc = netloc
|
||||||
self.path = path
|
self.path = path
|
||||||
|
self.query = pieces.query
|
||||||
|
|
||||||
|
|
||||||
def http_response_iterator(conn, response, size):
|
def http_response_iterator(conn, response, size):
|
||||||
|
|
|
@ -184,6 +184,15 @@ class TestHttpStore(base.StoreBaseTest,
|
||||||
self.assertRaises(exceptions.BadStoreUri,
|
self.assertRaises(exceptions.BadStoreUri,
|
||||||
location.get_location_from_uri, uri)
|
location.get_location_from_uri, uri)
|
||||||
|
|
||||||
|
def test_http_store_location_get_uri(self):
|
||||||
|
"""Test for HTTP URI with and without query"""
|
||||||
|
uris = ["http://netloc/path/to/file.tar.gz"
|
||||||
|
"http://netloc/path/to/file.tar.gz?query=text",
|
||||||
|
]
|
||||||
|
for uri in uris:
|
||||||
|
loc = location.get_location_from_uri(uri, conf=self.conf)
|
||||||
|
self.assertEqual(uri, loc.store_location.get_uri())
|
||||||
|
|
||||||
def test_http_get_raises_remote_service_unavailable(self):
|
def test_http_get_raises_remote_service_unavailable(self):
|
||||||
"""Test http store raises RemoteServiceUnavailable."""
|
"""Test http store raises RemoteServiceUnavailable."""
|
||||||
uri = "http://netloc/path/to/file.tar.gz"
|
uri = "http://netloc/path/to/file.tar.gz"
|
||||||
|
|
Loading…
Reference in New Issue