You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Avoid installing middleware if Content-Encoding is set at all (#1560)
The previous check for "gzip" ignored the possibility of other `Content-Encoding` values, such as Brotli’s ``br``, which the middleware could also not touch. Instead, do not attempt to alter the content for *any* `Content-Encoding`.
I tested by installing django-brotli in the example app below the toolbar middleware and hitting it with:
```
curl http://localhost:8000/ -H 'Accept-Encoding: br'
```
Without the change, it would crash with:
```
File "/.../debug_toolbar/middleware.py", line 87, in __call__
content = response.content.decode(response.charset)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc7 in position 1: invalid continuation byte
```
After, it is fixed.
0 commit comments