Python 通过GAE头发布请求
我从GAE Flask服务向其他GAE Flask服务发送POST请求Python 通过GAE头发布请求,python,google-app-engine,flask,http-headers,urllib,Python,Google App Engine,Flask,Http Headers,Urllib,我从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(CUSTO
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不支持标题内容长度和主机!
如何将POST请求从GAE发送到其他GAE端点???您在删除标题的语句中有一个输入错误,这就是导致错误的原因:
del readytogo.headers['Content-Lenght']
而不是
del readytogo.headers['Content-Length']