title: TypeError: EnvironHeaders([•••]) is not JSON serializable
body: <p>I want to turn incoming HTTP requests' headers into dictionaries and clone then via the "JSON trick." <code>request.headers</code> is an object that acts like a dictionary, but actually isn't a dictionary.</p>
  
  <pre><code>json.loads(json.dumps(request.headers))
  </code></pre>
  
  <p>The above-mentioned line of code results in this error:</p>
  
  <blockquote>
    <p>TypeError: EnvironHeaders([•••]) is not JSON serializable</p>
  </blockquote>
  
  <p>How do I convert a <code>werkzeug.datastructures.EnvironHeaders</code> object to a dictionary?</p>
  
  <hr>
  
  <p><strong>Attempt #1:</strong></p>
  
  <pre><code>json.loads(json.dumps({k: v for k, v in request.headers.iteritems()}))
  </code></pre>
  
  <p><strong>Attempt #2:</strong></p>
  
  <pre><code>json.loads(json.dumps({k: request.headers[k] for k in request.headers.keys()}))
  </code></pre>
  
  <p>Both of them throw this exception:</p>
  
  <blockquote>
    <p>ValueError: too many values to unpack</p>
  </blockquote>