简体   繁体   English

从Restlet获取Jersey协议

[英]Get Jersey protocol from restlet

Is there a way to get the protocol which was used to access a restlet? 有没有办法获取用来访问Restlet的协议? I would to implement like a slightly different behavior when accessing a servlet via HTTPS for example. 例如,当通过HTTPS访问servlet时,我会实现一种稍微不同的行为。 How can I check this? 我该如何检查?

Apparently, you can just inject your HttpServletRequest request like this: 显然,您可以像这样注入HttpServletRequest请求:

@PUT
@Path("{storage}/{repository}/{path:.*}")
public void upload(@PathParam("storage") String storage,
                   @PathParam("repository") String repository,
                   @PathParam("path") String path,
                   @Context HttpServletRequest request)
        throws IOException,
               AuthenticationException
{
    System.out.println("Using protocol " + request.getRequestURL().toString().split(":")[0]);
}

And this will do the trick. 这将解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM