【发布时间】:2018-03-26 04:07:32
【问题描述】:
我在 Google App Engine 上运行了两项服务(MS1 和 MS2)。 MS1 部署在标准环境中,MS2 部署在灵活环境中。我正在调用从标准环境到灵活环境的 API。我想确保 MS2 只接受来自 MS1 的请求。所以,我决定使用 App Engine 的this 功能。我在 MS1 中将 X-Appengine-Inbound-Appid 标头和 setInstanceFollowRedirects 设置为 false,但看起来 App Engine 正在删除此标头。我在 MS2 中找不到这个标头。
HttpHeaders headers = new HttpHeaders();
headers.add("X-Appengine-Inbound-Appid", ApiProxy.getCurrentEnvironment().getAppId());
HttpEntity<MergePdfsResource> entity = new HttpEntity<MergePdfsResource>(mergePdfsResource, headers);
restTemplate.setRequestFactory(new SimpleClientHttpRequestFactory() {
protected void prepareConnection(HttpURLConnection connection, String httpMethod) throws IOException {
super.prepareConnection(connection, httpMethod);
connection.setInstanceFollowRedirects(false);
}
});
ResponseEntity<SomeClass> response = restTemplate.postForEntity(apiUrl, entity, SomeClass.class);
【问题讨论】:
标签: spring google-app-engine spring-restcontroller spring-rest google-flexible