I've followed many tutorials and sample sample code but I am yet to see a way to access client's HTTP header, hostname etc like the way we can in Servlet's request object.
How do I go about it?
Let's say I've onOpen defined as-
@OnOpen
public void onOpen(Session session) {
}
In above method, is there a way I can access underlying HTTP connection details using session field? I am okay even if I can get to underlying Servlet (if there is any)
see chapter 4.1.1.5 at Tyrus user guide. It requires some amount of work to get the info from ServerEnpointConfig.Configurator to endpoint instance, but it can be done. (see ModifyRequestResponseHeadersTest.java)
Based on link1 and link2
I finally figured out that we can get the client IP with the following two classes, actually you can do more with the exposed httpservletRequest...
ServletAwareConfigurator .java
GetHttpSessionSocket.java