【发布时间】:2017-11-06 08:05:25
【问题描述】:
使用 python 请求,我发送了包含 {'foo': 'bar'} 的标头。
发送代码是这样的:
session = requests.Session()
session.headers.update({'foo':'bar'})
session.post('http://localhost:8000/whatever', json={a=1, b=2})
我还尝试了不使用会话并使用明确的 headers={'foo':'bar'}。结果相同。
在我的接收方式中:
@app.post('/whatever')
def do_something():
do_something_with(request.get_header('foo'))
我发现 foo 不见了。为什么会这样?我确定它在发送会话中存在。
【问题讨论】:
-
如果重要的话,这是在 python3.5 下
标签: python python-requests bottle