【发布时间】:2014-03-03 12:59:41
【问题描述】:
我在 Google App Engine 上使用 python-request,但它在 HTTPS 上没有按预期工作。我们来看一个例子:
import requests
requests.get('https://www.digitalocean.com')
如果我在终端中执行该行,它会完美运行。响应为 200 OK(无重定向)。
但是,如果我在 GAE 上执行它,则会引发 TooManyRedirects 错误。 试图弄清楚我使用allow_redirects = False执行的问题是什么,我可以看到响应是指向相同url的重定向(301)!!! ('location' 标头值为 'https://www.digitalocean.com')。这显然(当 allow_redirect=True 时)反复发生,直到引发 TooManyRedirects 错误。
因此,python-requests 似乎不适用于 HTTPS 的 GAE(我已经使用多个 URL 进行了测试)。但是 HTTP 完美运行。
知道发生了什么吗?
提前致谢。
【问题讨论】:
-
我也有这个问题。
-
如果有帮助,我最近升级到 urllib3==1.71 和 requests==2.2.1
-
在此处提交了 AppEngine 问题:code.google.com/p/googleappengine/issues/detail?id=10562
-
我在 python-requests repo 中做了同样的事情:github.com/kennethreitz/requests/issues/1905
标签: python google-app-engine python-2.7 python-requests