V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
ns2250225
V2EX  ›  Python

关于 django channels 的一个 BUG,求大神指点

  •  
  •   ns2250225 ·
    ns2250225 · 2018-03-08 17:44:34 +08:00 · 1688 次点击
    这是一个创建于 2237 天前的主题,其中的信息可能已经有所发展或是发生改变。

    使用 django channels 前

    • 前端请求的 header 里面,我设置了一个字段 X_USERNAME
    • django 后端可以通过 request.META.get('X_USERNAME') 获取到相应的值

    使用 django channels 后

    • django 后端通过 request.META,里面根本没有了 X_USERNAME 这个 KEY

    • 求大神指点,ORZ

    1 条回复    2018-03-09 17:08:43 +08:00
    ns2250225
        1
    ns2250225  
    OP
       2018-03-09 17:08:43 +08:00
    = =,自己解决了,前端的请求头里面不要用自定义的 X_USERNAME,而要用 Authorization,这样设置之后,后端用 request.META.get('HTTP_AUTHORIZATION')就能拿到值了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5375 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 08:20 · PVG 16:20 · LAX 01:20 · JFK 04:20
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.