I need to get all the Django request headers. From what I’ve read, Django simply dumps everything into the request.META variable along with a lot of other data. What would be the best way to get all the headers that the client sent to my Django application?
I’m going use these to build a httplib request.
According to the documentation
request.METAis a “standard Python dictionary containing all available HTTP headers”. If you want to get all the headers you can simply iterate through the dictionary.Which part of your code to do this depends on your exact requirement. Anyplace that has access to
requestshould do.Update
From the documentation:
(Emphasis added)
To get the
HTTPheaders alone, just filter by keys prefixed withHTTP_.Update 2
Sure. Here is one way to do it.