Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Filter responses to run html tidy for

Marek Brzóskaca5b95bb8f9c
diff --git a/saleor/middleware.py b/saleor/middleware.py
index c0ad63441f..f795815c31 100644
--- a/saleor/middleware.py
+++ b/saleor/middleware.py
@@ -8,7 +8,11 @@ logger = logging.getLogger('saleor')
class CheckHTML(object):
def process_response(self, _request, response):
- if settings.DEBUG and settings.WARN_ABOUT_INVALID_HTML5_OUTPUT:
+ if (
+ settings.DEBUG
+ and settings.WARN_ABOUT_INVALID_HTML5_OUTPUT
+ and 200 <= response.status.code < 300
+ ):
proc = Popen(["tidy"], stdout=PIPE, stderr=PIPE, stdin=PIPE)
_out, err = proc.communicate(response.content)
for l in err.split('\n\n')[0].split('\n')[:-2]: