@@ -69,20 +69,18 @@ def __call__(self, request):
69
69
70
70
response = self .generate_server_timing_header (response , toolbar .enabled_panels )
71
71
72
+ # Always render the toolbar for the history panel, even if it is not
73
+ # included in the response.
74
+ rendered = toolbar .render_toolbar ()
75
+
72
76
# Check for responses where the toolbar can't be inserted.
73
77
content_encoding = response .get ("Content-Encoding" , "" )
74
78
content_type = response .get ("Content-Type" , "" ).split (";" )[0 ]
75
- if any (
76
- (
77
- getattr (response , "streaming" , False ),
78
- "gzip" in content_encoding ,
79
- content_type not in _HTML_TYPES ,
80
- request .is_ajax (),
81
- )
79
+ if (
80
+ getattr (response , "streaming" , False )
81
+ or "gzip" in content_encoding
82
+ or content_type not in _HTML_TYPES
82
83
):
83
- # If a AJAX or JSON request, render the toolbar for the history.
84
- if request .is_ajax () or content_type == "application/json" :
85
- toolbar .render_toolbar ()
86
84
return response
87
85
88
86
# Insert the toolbar in the response.
@@ -91,7 +89,7 @@ def __call__(self, request):
91
89
pattern = re .escape (insert_before )
92
90
bits = re .split (pattern , content , flags = re .IGNORECASE )
93
91
if len (bits ) > 1 :
94
- bits [- 2 ] += toolbar . render_toolbar ()
92
+ bits [- 2 ] += rendered
95
93
response .content = insert_before .join (bits )
96
94
if "Content-Length" in response :
97
95
response ["Content-Length" ] = len (response .content )
0 commit comments