未记录urlfetch URL的最大长度? [英] Undocumented max length for urlfetch URL?
问题描述
我有一个App Engine应用程序试图抓取一个长url。经过试验,似乎由于某些原因,App Engine将获取的网址长度限制为2047.这是错误的堆栈跟踪:
I have an App Engine app that tries to fetch a long url. After experimenting it seems that for some reason App Engine limits the length of fetched urls to 2047. This is the stack trace for the error:
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/urlfetch.py", line 270, in fetch
return rpc.get_result()
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 612, in get_result
return self.__get_result_hook(self)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/urlfetch.py", line 386, in _get_fetch_result
'Invalid request URL: ' + url + error_detail)
InvalidURLError: Invalid request URL: <LONG URL>
该限制也适用于开发环境。在App Engine sdk( urlfetch_stub.py
)中找到以下代码:
The limit also applies in the development env. where I found the following code in the App Engine sdk (urlfetch_stub.py
):
_MAX_URL_LENGTH = 2048
if len(request.url()) >= _MAX_URL_LENGTH:
logging.error('URL is too long: %s...' % request.url()[:50])
raise apiproxy_errors.ApplicationError(
urlfetch_service_pb.URLFetchServiceError.INVALID_URL)
为什么这个限制存在?有没有办法绕过它?对于我来说,获取非常长的网址非常重要(我使用的REST API服务需要很长的网址)。
Why does this limit exist? Is there a way to bypass it? It is really critical for me to fetch very long urls (I'm using a REST API service that require long urls).
推荐答案
这是一个已经报告的问题,将来可能会解决。所以我想你现在只需等待,或者使用某种形式的URL缩短(yuck)。
This is an already reported issue which may be addressed in future. So I guess you have to just wait for now, or use some form of URL shortening (yuck).
You can see the issue here and the related stack question here.
简而言之,该限制已添加到存根以匹配GAE上的实现,因此至少您发现此问题很快。我不知道为什么它是有限的。
In short, that limit was added to the stub to match the implementation on GAE so at least you found this issue quickly. I have no idea why it is limited.
这篇关于未记录urlfetch URL的最大长度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!