diff --git a/manila/api/openstack/wsgi.py b/manila/api/openstack/wsgi.py index 9f9846f6ac..c2ac051f79 100644 --- a/manila/api/openstack/wsgi.py +++ b/manila/api/openstack/wsgi.py @@ -54,6 +54,7 @@ API_VERSION_REQUEST_HEADER = 'X-OpenStack-Manila-API-Version' EXPERIMENTAL_API_REQUEST_HEADER = 'X-OpenStack-Manila-API-Experimental' V1_SCRIPT_NAME = '/v1' +V2_SCRIPT_NAME = '/v2' class Request(webob.Request): @@ -219,7 +220,9 @@ class Request(webob.Request): Microversions starts with /v2, so if a client sends a /v1 URL, then ignore the headers and request 1.0 APIs. """ - if not self.script_name: + if not self.script_name or not (V1_SCRIPT_NAME in self.script_name or + V2_SCRIPT_NAME in self.script_name): + # The request is on the base URL without a major version specified self.api_version_request = api_version.APIVersionRequest() elif V1_SCRIPT_NAME in self.script_name: self.api_version_request = api_version.APIVersionRequest('1.0') diff --git a/manila/tests/api/openstack/test_wsgi.py b/manila/tests/api/openstack/test_wsgi.py index c6b8f89550..3332b08423 100644 --- a/manila/tests/api/openstack/test_wsgi.py +++ b/manila/tests/api/openstack/test_wsgi.py @@ -177,7 +177,7 @@ class RequestTest(test.TestCase): self.assertIsNone(request.set_api_version_request()) - if not resource: + if not resource or not ('/v1' in resource or '/v2' in resource): self.assertEqual(api_version.APIVersionRequest(), request.api_version_request) elif 'v1' in resource: diff --git "a/releasenotes/notes/bug-1818081-fix-inferred-script-name-in-case-of-proxy-urls-e33466af856708b4.yaml\t\t\t" "b/releasenotes/notes/bug-1818081-fix-inferred-script-name-in-case-of-proxy-urls-e33466af856708b4.yaml\t\t\t" index 57bcb3dd3e..5b6f352276 100644 --- "a/releasenotes/notes/bug-1818081-fix-inferred-script-name-in-case-of-proxy-urls-e33466af856708b4.yaml\t\t\t" +++ "b/releasenotes/notes/bug-1818081-fix-inferred-script-name-in-case-of-proxy-urls-e33466af856708b4.yaml\t\t\t" @@ -3,5 +3,5 @@ fixes: - | When manila API is run behind a proxy webserver, the API service was parsing the major API version requested incorrectly, leading to incorrect - responses. This behavior has now been fixed. See `launchpad bug 1815038 + responses. This behavior has now been fixed. See `launchpad bug 1818081 `_ for more details. \ No newline at end of file