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',
|
||||
'Debug',
|
||||
'Healthcheck',
|
||||
'HTTPProxyToWSGI',
|
||||
'RequestId',
|
||||
'RequestBodySizeLimiter',
|
||||
'SSLMiddleware']
|
||||
@ -24,6 +25,7 @@ from oslo_middleware.correlation_id import CorrelationId
|
||||
from oslo_middleware.cors import CORS
|
||||
from oslo_middleware.debug import Debug
|
||||
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.sizelimit import RequestBodySizeLimiter
|
||||
from oslo_middleware.ssl import SSLMiddleware
|
||||
|
@ -11,11 +11,11 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from debtcollector import removals
|
||||
from oslo_middleware import base
|
||||
|
||||
|
||||
class HTTPProxyToWSGIMiddleware(base.ConfigurableMiddleware):
|
||||
class HTTPProxyToWSGI(base.ConfigurableMiddleware):
|
||||
"""HTTP proxy to WSGI termination middleware.
|
||||
|
||||
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")
|
||||
if v:
|
||||
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):
|
||||
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()
|
||||
def fake_app(req):
|
||||
return util.application_uri(req.environ)
|
||||
|
||||
self.middleware = http_proxy_to_wsgi.HTTPProxyToWSGIMiddleware(
|
||||
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):
|
||||
response = self.request.get_response(self.middleware)
|
||||
|
Loading…
Reference in New Issue
Block a user