How To Send Request Header To Jetty WebSocket From JavaScript Client ?
What I am doing ?
At Client Side.
- Need To add service name and service version in request header at client side
- Send to server
At Server Side.
- Identify the service from the request header
- Using that create corresponding input translator (using GSON)
- Create service input using that translator
- Call the service.
I can use org.eclipse.jetty.websocket.api.annotations.WebSocket as to get service name and version at server side. But..... How can I set the header information at client side?
@OnWebSocketMessage
public void onText(Session session, String message) {
if (session.isOpen()) {
System.out.println(session.getUpgradeRequest().getHeader("service"));
System.out.println(session.getUpgradeRequest().getHeader("version"));
System.out.printf("Echoing back message [%s]%n", message);
session.getRemote().sendString(message, null);
}
}
Thanks for your support...