I have a Java Servlet that is a web application firewall. It forwards all legitimate traffic to the backend application it protects in a very simple way:
for (int length = 0; (length = input.read(byteBuffer)) > 0;) {
output.write(byteBuffer, 0, length);
}
Here input and output are the servlet streams.
This works fine as long as requests are HTTP only (POST can be forwarded other way around) but WebSocket protocol cannot be forwarded this way.
Is it possible to forward WebSocket traffic between the two Java Streams in one or another way? I could check the path to know in advance there it will be WebSocket traffic.