How to get raw request headers in django?

How to get the original request headers in django? I know the HttpRequest.META dictionary, this is not what I want, I just want the original headers to be string. Is there any way to get it?

+5
source share
1 answer

AFAIK, since there is no way from the existing django releases (tagged <= 1.2.5) to get the original HTTP headers from the object request.

However, looking at the source in the dev (R15523) trunk for django.http.HttpRequests , the base class for the request object exposes a file interface that assumes that one could get the original headers using something like:

def dump_request_headers(request):
    dump = "".join(request.xreadlines())
    return HttpResponse("<pre>%s</pre>" % dump)

, , , . , , .

+2

All Articles