如何在REST应用程序中获取“X-Forwarded-Proto”头?

时间:2014-04-24 00:31:42

标签: java web-services http rest jax-ws

我在tomcat上运行了一个REST应用程序。我正在使用server.xml redirectPort参数将http请求转发到https。

现在,在服务器端,我想阅读 X-Forwarded-Proto 标头,以确定是否正在重定向请求。

我的代码如下所示:

@Context
UriInfo uriInfo;

@Context
Request request;

protected Response checkRedirect(SecurityContext sc)
{

   String forwardedProtocol = ((ContainerRequest)request).getHeaderValue("X-Forwarded-Proto");

}

然而,这不起作用。似乎请求对象只能访问少数http标头。

有人可以建议我获取标题值的最佳方法吗?提前谢谢。

1 个答案:

答案 0 :(得分:0)

你需要instruct tomcat注意。

相关问题