File tree 4 files changed +23
-4
lines changed
4 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ def get_headers(self, request):
24
24
observe_request = self .toolbar .get_observe_request ()
25
25
store_id = getattr (self .toolbar , "store_id" )
26
26
if store_id and observe_request (request ):
27
- headers ["DJDT-STORE-ID " ] = store_id
27
+ headers ["djdt-store-id " ] = store_id
28
28
return headers
29
29
30
30
@property
Original file line number Diff line number Diff line change @@ -264,8 +264,13 @@ const djdt = {
264
264
const origOpen = XMLHttpRequest . prototype . open ;
265
265
XMLHttpRequest . prototype . open = function ( ) {
266
266
this . addEventListener ( "load" , function ( ) {
267
- let store_id = this . getResponseHeader ( "djdt-store-id" ) ;
268
- if ( store_id !== null ) {
267
+ // Chromium emits a "Refused to get unsafe header" uncatchable warning
268
+ // when the header can't be fetched. While it doesn't impede execution
269
+ // it's worrisome to developers.
270
+ if (
271
+ this . getAllResponseHeaders ( ) . indexOf ( "djdt-store-id" ) >= 0
272
+ ) {
273
+ let store_id = this . getResponseHeader ( "djdt-store-id" ) ;
269
274
store_id = encodeURIComponent ( store_id ) ;
270
275
const dest = `${ sidebar_url } ?store_id=${ store_id } ` ;
271
276
slowjax ( dest ) . then ( function ( data ) {
Original file line number Diff line number Diff line change @@ -142,7 +142,7 @@ Toolbar options
142
142
143
143
* ``OBSERVE_REQUEST_CALLBACK ``
144
144
145
- Default: ``'debug_toolbar.middleware .observe_request' ``
145
+ Default: ``'debug_toolbar.toolbar .observe_request' ``
146
146
147
147
This is the dotted path to a function used for determining whether the
148
148
toolbar should update on AJAX requests or not. The default checks are that
Original file line number Diff line number Diff line change @@ -99,6 +99,20 @@ def test_history_sidebar_invalid(self):
99
99
response = self .client .get (reverse ("djdt:history_sidebar" ))
100
100
self .assertEqual (response .status_code , 400 )
101
101
102
+ def test_history_headers (self ):
103
+ """Validate the headers injected from the history panel."""
104
+ response = self .client .get ("/json_view/" )
105
+ store_id = list (DebugToolbar ._store )[0 ]
106
+ self .assertEqual (response .headers ["djdt-store-id" ], store_id )
107
+
108
+ @override_settings (
109
+ DEBUG_TOOLBAR_CONFIG = {"OBSERVE_REQUEST_CALLBACK" : lambda request : False }
110
+ )
111
+ def test_history_headers_unobserved (self ):
112
+ """Validate the headers aren't injected from the history panel."""
113
+ response = self .client .get ("/json_view/" )
114
+ self .assertNotIn ("djdt-store-id" , response .headers )
115
+
102
116
def test_history_sidebar (self ):
103
117
"""Validate the history sidebar view."""
104
118
self .client .get ("/json_view/" )
You can’t perform that action at this time.
0 commit comments