[Answered ]-Read custom headers passed in ajax

2👍

You are right about keys being prefixed with ‘HTTP_’.

From the docs, this is how Django builds the keys:

With the exception of CONTENT_LENGTH and CONTENT_TYPE, as given above, any HTTP headers in the request are converted to META keys by converting all characters to uppercase, replacing any hyphens with underscores and adding an HTTP_ prefix to the name. So, for example, a header called X-Bender would be mapped to the META key HTTP_X_BENDER.

You can loop through all the headers and reverse this process to obtain the original header key.

Leave a comment