In log.py, we're attempting to log the request headers when a
500-series error occurs, but tornado.httputil.HTTPHeaders isn't a dict -
it inherits from collections.MutableMapping. So it fails during
JSON serialization. The fix is to convert it to a dict first.
Unfortunately, the HTTPHeaders class doesn't expose any methods
to access the underlying dictionary (`request.headers._dict`) directly,
so we recreate it using the public API.