【发布时间】:2019-02-10 12:18:14
【问题描述】:
我从 GAE Flask 服务向其他 GAE Flask 服务发送 POST 请求
try:
service_url = 'http://localhost:4040/getservice'
headers = {
'Content-Type': 'application/json',
'Cache-Control': 'no-cache',
'Auth-Key': AUTH_KEY,
'Customer': str(CUSTOMER)
}
s = Session()
req = requests.Request('POST', service_url, data=conf, headers=headers)
readytogo = req.prepare()
#del readytogo.headers['Content-Lenght']
#del readytogo.headers['Host']
module = s.send(readytogo)
except Exception as e:
print('error')
print(e)
return e
但我有这个错误:
Stripped prohibited headers from URLFetch request: ['Host', 'Content-Length']
如果我删除了该标题,我在控制台中会出现此错误:
error
'content-lenght'
页面中出现此错误:
An internal error occurred:
'exceptions.KeyError' object is not callable
See logs for full stacktrace.
GAE 不支持标头 Content-Lenght 和 Host! 如何从 GAE 向其他 GAE 端点发送 POST 请求???
【问题讨论】:
标签: python google-app-engine flask http-headers urllib