[racket] Intercepting WebSocket connections to the Racket web server?

From: Alexis King (lexi.lambda at gmail.com)
Date: Sat Mar 21 21:44:12 EDT 2015

The WebSocket handshake is intentionally implemented in such a way so that WebSocket connections can be performed using the same port that the HTTP server is running on. This is implemented by making the handshake a standard HTTP 1.1 GET request with an “Upgrade: websocket” header.

I’m interested in doing this using the Racket web server, but I’m not sure how to intercept websocket connections. I’m completely willing to implement all the websocket connection logic myself, I just need to know how to detect headers sent with that Upgrade header before the web server has a chance to handle them so that I can pass the connection off to my own websocket logic.

What’s the proper way to achieve this sort of thing?


Posted on the users mailing list.