I'm trying to create a WebSocket client to connect to an existing server (mtgox api).
As a starting point, to figure out connecting to WebSockets, I found this example code https://github.com/jaspervdj/websockets/blob/master/example/client.hs
The problem is that Mtgox requires headers to be sent along when it connects, I'm just not sure how to send them.
Update: To help work this out, I created a simple websocket server too. When I connect to it via a JavaScript WebSocket from my Chrome JavaScript console, I see the following headers:
requestHeaders = [("Upgrade","websocket"),("Connection","Upgrade"),
("Host","127.0.0.1:8001"),("Origin","chrome://newtab"),("Pragma","no-cache"),
("Cache-Control","no-cache"),("Sec-WebSocket-Key","yOsPEMHx9AyT9u3ssNma/Q=="),
("Sec-WebSocket-Version","13"),("Sec-WebSocket-Extensions","x-webkit-deflate-frame"),
("User-Agent","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36")]
Whereas, when I connect through via the Haskell client, I see only the following headers:
requestHeaders = [("Host","127.0.0.1"),("Connection","Upgrade"),
("Upgrade","websocket"),("Sec-WebSocket-Key","X3hMDW4fAau53dbz7w4MTw=="),
("Sec-WebSocket-Version","13")]
I don't know which of the headers are actually required by MtGox, but my plan was to just send the same ones that Chrome sends, since that works.