我有两个 AppEngine 模块,一个运行 Python 的默认模块和一个运行 Java 的“java”模块。我正在使用 urlfetch 从默认模块访问 Java 模块。根据 AppEngine 文档 (cloud.google.com/appengine/docs/java/appidentity),我可以通过检查 X-Appengine-Inbound-Appid header 在 Java 模块中验证请求来自同一应用程序中的模块.
但是,未设置此 header (在生产部署中)。我在 Python 模块中使用 urlfetch,如下所示:
hostname = modules.get_hostname(module="java")
hostname = hostname.replace('.', '-dot-', 2)
url = "http://%s/%s" % (hostname, "_ah/api/...")
result = urlfetch.fetch(url=url, follow_redirects=False, method=urlfetch.GET)
请注意,我使用的是符号:
<version>-dot-<module>-dot-<app>.appspot.com
而不是符号:
<version>.<module>.<app>.appspot.com
由于某种原因导致 404 响应。
在 Java 模块中,我正在运行一个 servlet 过滤器,它按如下方式查看所有请求 header :
Enumeration<String> headerNames = httpRequest.getHeaderNames();
while (headerNames.hasMoreElements()) {
String headerName = headerNames.nextElement();
String headerValue = httpRequest.getHeader(headerName);
mLog.info("Header: " + headerName + " = " + headerValue);
}
AppEngine 确实设置了一些 header ,例如X-AppEngine-国家。但未设置 X-Appengine-Inbound-Appid header 。
为什么我没有看到记录的行为?任何建议将不胜感激。
最佳答案
看看我在 Google groups 上得到的回答,这导致了一个 issue opened on the public issue tracker .
正如我收到的答案中所建议的那样,您可以关注那里的问题以获取任何更新。
关于google-app-engine - 未设置 X-Appengine-Inbound-Appid header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26782249/