title: How to add headers when connecting to a websocket in Haskell
body: <p>I'm trying to create a WebSocket client to connect to an existing server (<a href="https://en.bitcoin.it/wiki/MtGox/API/Streaming" rel="nofollow">mtgox api</a>).</p>
  
  <p>As a starting point, to figure out connecting to WebSockets, I found this example code <a href="https://github.com/jaspervdj/websockets/blob/master/example/client.hs" rel="nofollow">https://github.com/jaspervdj/websockets/blob/master/example/client.hs</a></p>
  
  <p>The problem is that Mtgox requires headers to be sent along when it connects, I'm just not sure how to send them.</p>
  
  <p><strong>Update:</strong> 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:</p>
  
  <pre><code> 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")]
  </code></pre>
  
  <p>Whereas, when I connect through via the Haskell client, I see only the following headers:</p>
  
  <pre><code>requestHeaders = [("Host","127.0.0.1"),("Connection","Upgrade"),
  ("Upgrade","websocket"),("Sec-WebSocket-Key","X3hMDW4fAau53dbz7w4MTw=="),
  ("Sec-WebSocket-Version","13")]
  </code></pre>
  
  <p>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.</p>