Custom HTTP Header in Django

后端 未结 6 1856
春和景丽
春和景丽 2020-12-30 19:23

I use a custom http header for URL signature just called \"sign\", how to get such custom HTTP header value in Django?

6条回答
  •  傲寒
    傲寒 (楼主)
    2020-12-30 20:12

    From the Django documentation:

    https://docs.djangoproject.com/en/2.1/ref/request-response/#django.http.HttpRequest.META

    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.

提交回复
热议问题