add missing shortcut for HTTPProxyToWSGI middleware
we should've added a shortcut to oslo_middleware/__init__ to hide path. additionally we shouldn't have added Middleware to class name as it's redundant Change-Id: Id581180c24006aa142eb8bf086eb7fc42835cff5 Closes-Bug: #1514507
This commit is contained in:
parent
b4ad4f9073
commit
e11c08eef8
@ -15,6 +15,7 @@ __all__ = ['CatchErrors',
|
|||||||
'CORS',
|
'CORS',
|
||||||
'Debug',
|
'Debug',
|
||||||
'Healthcheck',
|
'Healthcheck',
|
||||||
|
'HTTPProxyToWSGI',
|
||||||
'RequestId',
|
'RequestId',
|
||||||
'RequestBodySizeLimiter',
|
'RequestBodySizeLimiter',
|
||||||
'SSLMiddleware']
|
'SSLMiddleware']
|
||||||
@ -24,6 +25,7 @@ from oslo_middleware.correlation_id import CorrelationId
|
|||||||
from oslo_middleware.cors import CORS
|
from oslo_middleware.cors import CORS
|
||||||
from oslo_middleware.debug import Debug
|
from oslo_middleware.debug import Debug
|
||||||
from oslo_middleware.healthcheck import Healthcheck
|
from oslo_middleware.healthcheck import Healthcheck
|
||||||
|
from oslo_middleware.http_proxy_to_wsgi import HTTPProxyToWSGI
|
||||||
from oslo_middleware.request_id import RequestId
|
from oslo_middleware.request_id import RequestId
|
||||||
from oslo_middleware.sizelimit import RequestBodySizeLimiter
|
from oslo_middleware.sizelimit import RequestBodySizeLimiter
|
||||||
from oslo_middleware.ssl import SSLMiddleware
|
from oslo_middleware.ssl import SSLMiddleware
|
||||||
|
@ -11,11 +11,11 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
# implied. See the License for the specific language governing permissions and
|
# implied. See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
from debtcollector import removals
|
||||||
from oslo_middleware import base
|
from oslo_middleware import base
|
||||||
|
|
||||||
|
|
||||||
class HTTPProxyToWSGIMiddleware(base.ConfigurableMiddleware):
|
class HTTPProxyToWSGI(base.ConfigurableMiddleware):
|
||||||
"""HTTP proxy to WSGI termination middleware.
|
"""HTTP proxy to WSGI termination middleware.
|
||||||
|
|
||||||
This middleware overloads WSGI environment variables with the one provided
|
This middleware overloads WSGI environment variables with the one provided
|
||||||
@ -68,3 +68,8 @@ class HTTPProxyToWSGIMiddleware(base.ConfigurableMiddleware):
|
|||||||
v = req.environ.get("HTTP_X_FORWARDED_PREFIX")
|
v = req.environ.get("HTTP_X_FORWARDED_PREFIX")
|
||||||
if v:
|
if v:
|
||||||
req.environ['SCRIPT_NAME'] = v + req.environ['SCRIPT_NAME']
|
req.environ['SCRIPT_NAME'] = v + req.environ['SCRIPT_NAME']
|
||||||
|
|
||||||
|
|
||||||
|
@removals.remove
|
||||||
|
class HTTPProxyToWSGIMiddleware(HTTPProxyToWSGI):
|
||||||
|
"""Placeholder for backward compatibility"""
|
||||||
|
@ -24,13 +24,22 @@ class TestHTTPProxyToWSGI(test_base.BaseTestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestHTTPProxyToWSGI, self).setUp()
|
super(TestHTTPProxyToWSGI, self).setUp()
|
||||||
|
|
||||||
|
@webob.dec.wsgify()
|
||||||
|
def fake_app(req):
|
||||||
|
return util.application_uri(req.environ)
|
||||||
|
|
||||||
|
self.middleware = http_proxy_to_wsgi.HTTPProxyToWSGI(fake_app)
|
||||||
|
self.request = webob.Request.blank('/foo/bar', method='POST')
|
||||||
|
|
||||||
|
def test_backward_compat(self):
|
||||||
@webob.dec.wsgify()
|
@webob.dec.wsgify()
|
||||||
def fake_app(req):
|
def fake_app(req):
|
||||||
return util.application_uri(req.environ)
|
return util.application_uri(req.environ)
|
||||||
|
|
||||||
self.middleware = http_proxy_to_wsgi.HTTPProxyToWSGIMiddleware(
|
self.middleware = http_proxy_to_wsgi.HTTPProxyToWSGIMiddleware(
|
||||||
fake_app)
|
fake_app)
|
||||||
self.request = webob.Request.blank('/foo/bar', method='POST')
|
response = self.request.get_response(self.middleware)
|
||||||
|
self.assertEqual(b"http://localhost:80/", response.body)
|
||||||
|
|
||||||
def test_no_headers(self):
|
def test_no_headers(self):
|
||||||
response = self.request.get_response(self.middleware)
|
response = self.request.get_response(self.middleware)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user