Commit 1559500
authored
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.1 parent afc5dfc commit 1559500
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
| 81 | + | |
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| |||
0 commit comments