Custom HTTP Header in Django

后端 未结 6 1989
春和景丽
春和景丽 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:13

    As of Django 2.2 you can use the HttpRequest.headers dictionary which provides case-insensitive dictionary of request headers, like such:

    my_header = request.headers.get('x-my-custom-header')
    

    See django.http.HttpRequest.headers

提交回复
热议问题