How about changing this line to:

```python
if 'application/xhtml+xml' in environ.get('HTTP_ACCEPT', ''):
```