gpt4 book ai didi

java - 如何在REST应用程序中获取 "X-Forwarded-Proto" header ?

转载 作者:太空宇宙 更新时间:2023-11-04 14:55:31 24 4
gpt4 key购买 nike

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

现在,在服务器端,我想读取 X-Forwarded-Proto header 来确定请求是否被重定向。

我的代码如下所示:

@Context
UriInfo uriInfo;

@Context
Request request;

protected Response checkRedirect(SecurityContext sc)
{

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

}

但是,这不起作用。看起来请求对象只允许访问少数 http header 。

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

最佳答案

您需要instruct tomcat要注意了。

关于java - 如何在REST应用程序中获取 "X-Forwarded-Proto" header ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23257697/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com