2

Django では、多くのことが request.META にあり、現在のコードは request.META で HTTP_TOKEN のようなものをチェックするため、リクエストを送信するときにその URL にリクエストを送信して、受信サーバーでデータがリクエストに表示されるようにする必要があります。メタ。

そこにヘッダーが表示されると思ったので、これを試しました:

  python example:(I am sending request from javascript, but getting it work from any client is enough so I can implement finally using javascript).
  r = requests.get(url, headers={'HTTP_TOKEN': 'abc'})

しかし、そこからリクエストを受け取った後、request.META に HTTP_TOKEN のようなものは見つかりませんでした。

4

1 に答える 1

4

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.

https://docs.djangoproject.com/en/dev/ref/request-response/を参照してください。

したがって、あなたの場合、単に送信する必要があると思います{"TOKEN": "abc"}

于 2013-07-27T20:51:23.267 に答える