diff --git a/nova/api/wsgi.py b/nova/api/wsgi.py index a365d1320d65..4a74bb6a986e 100644 --- a/nova/api/wsgi.py +++ b/nova/api/wsgi.py @@ -12,12 +12,10 @@ """WSGI primitives used throughout the nova WSGI apps.""" import os -import sys from oslo_log import log as logging from paste import deploy import routes.middleware -import six import webob import nova.conf @@ -167,42 +165,6 @@ class Middleware(Application): return self.process_response(response) -class Debug(Middleware): - """Helper class for debugging a WSGI application. - - Can be inserted into any WSGI application chain to get information - about the request and response. - - """ - - @webob.dec.wsgify(RequestClass=Request) - def __call__(self, req): - print(('*' * 40) + ' REQUEST ENVIRON') - for key, value in req.environ.items(): - print(key, '=', value) - print() - resp = req.get_response(self.application) - - print(('*' * 40) + ' RESPONSE HEADERS') - for (key, value) in resp.headers.items(): - print(key, '=', value) - print() - - resp.app_iter = self.print_generator(resp.app_iter) - - return resp - - @staticmethod - def print_generator(app_iter): - """Iterator that prints the contents of a wrapper string.""" - print(('*' * 40) + ' BODY') - for part in app_iter: - sys.stdout.write(six.text_type(part)) - sys.stdout.flush() - yield part - print() - - class Router(object): """WSGI middleware that maps incoming requests to WSGI apps.""" diff --git a/nova/tests/unit/api/test_wsgi.py b/nova/tests/unit/api/test_wsgi.py index 4ad4055752b3..ba101ceaa865 100644 --- a/nova/tests/unit/api/test_wsgi.py +++ b/nova/tests/unit/api/test_wsgi.py @@ -19,9 +19,7 @@ Test WSGI basics and provide some helper functions for other WSGI tests. """ -import fixtures import routes -from six.moves import StringIO import webob from nova.api import wsgi @@ -30,27 +28,6 @@ from nova import test class Test(test.NoDBTestCase): - def test_debug(self): - """This tests optional middleware we have which dumps - the requests to stdout. - """ - self.output = StringIO() - self.useFixture(fixtures.MonkeyPatch('sys.stdout', self.output)) - - class Application(wsgi.Application): - """Dummy application to test debug.""" - - def __call__(self, environ, start_response): - start_response("200", [("X-Test", "checking")]) - return [b'Test result'] - - application = wsgi.Debug(Application()) - result = webob.Request.blank('/').get_response(application) - self.assertEqual(result.body, b"Test result") - self.assertIn( - '**************************************** REQUEST ENVIRON', - self.output.getvalue()) - def test_router(self): class Application(wsgi.Application):