Permalink
Browse files

Allow streaming html responses to pass through the middleware untouched.

  • Loading branch information...
ralphbean committed Apr 17, 2012
1 parent 5cc582c commit 3f4a5a4b91bbea9534760d7ea3497fea0513e157
Showing with 7 additions and 1 deletion.
  1. +7 −1 tw2/core/middleware.py
@@ -1,3 +1,4 @@
import types
import warnings
import webob as wo
from pkg_resources import iter_entry_points, DistributionNotFound
@@ -207,7 +208,12 @@ def __call__(self, environ, start_response):
ct = resp.headers.get('Content-Type', 'text/plain').lower()
if self.config.inject_resources and 'html' in ct:
should_inject = (
self.config.inject_resources
and 'html' in ct
and not isinstance(resp.app_iter, types.GeneratorType)
)
if should_inject:
body = resources.inject_resources(
resp.body,
encoding=resp.charset,

0 comments on commit 3f4a5a4

Please sign in to comment.