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
pc10201
V2EX  ›  Python

nginx+django+gunicorn 遇到 URL 空格转义问题~

  •  
  •   pc10201 · 2017-02-23 16:59:11 +08:00 · 1877 次点击
    这是一个创建于 2590 天前的主题,其中的信息可能已经有所发展或是发生改变。
    URL 如果是 123 456,浏览器点击后就会变成 123%20456
    在 django 自带的调试服务中,通过 URL 正则获取到的值是 123 456,一点问题没有

    但通过 nginx+django+gunicorn 部署到生产服务器,获取到的值是 123%20456,然后导致与数据库交互有一些错误,但感觉也不是 django 的 bug 啊~难道是 nginx+gunicorn 的问题?我是通过 proxy_pass 传递数据的~
    2 条回复    2017-03-08 20:03:52 +08:00
    lonelywheel
        1
    lonelywheel  
       2017-03-08 17:00:57 +08:00
    注意你的 url 里面 123 和 456 的空格,应该是空格 urlencode 转换成了%20
    pc10201
        2
    pc10201  
    OP
       2017-03-08 20:03:52 +08:00
    @lonelywheel 已经找到解决办法了,我把 gunicorn 的 worker 由 aiohttp 换成 gevent 就好了~估计是 aiohttp 的锅
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1198 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 23:16 · PVG 07:16 · LAX 16:16 · JFK 19:16
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.