Get a value from the WSGI environ dictionary as bytes. key and default should be strings.
(environ, key, default)
| 185 | |
| 186 | |
| 187 | def get_bytes_from_wsgi(environ, key, default): |
| 188 | """ |
| 189 | Get a value from the WSGI environ dictionary as bytes. |
| 190 | |
| 191 | key and default should be strings. |
| 192 | """ |
| 193 | value = environ.get(key, default) |
| 194 | # Non-ASCII values in the WSGI environ are arbitrarily decoded with |
| 195 | # ISO-8859-1. This is wrong for Django websites where UTF-8 is the default. |
| 196 | # Re-encode to recover the original bytestring. |
| 197 | return value.encode("iso-8859-1") |
| 198 | |
| 199 | |
| 200 | def get_str_from_wsgi(environ, key, default): |
no test coverage detected