简体   繁体   中英

Get raw request headers in django

Is there any way to get the full unprocessed HTTP request headers in django (hosted on elastic beanstalk?)

I would like to be able to analyze the ordering of the headers in particular, so unfortunately HttpRequest.META does not suffice for my use case.

No - you cannot do this at the Django level. The contents of HttpRequest.META are obtained directly from the WSGI handler . The structure of this object is defined in the WSGI specification .

The request headers are a dict even before Django gets anywhere near them - your WSGI handler (uwsgi/gunicorn/weurkzeug in development) is what parses the headers and passes the dict to your Django application. Django has no knowledge of the original, raw, request headers.

The only place to get the raw request would be at web server (Nginx/Apache etc) level. I know you can log these with Nginx - although you would be logging a substantial amount of data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM