Software / code / prosody-modules
Comparison
mod_websocket/mod_websocket.lua @ 844:a0987c0e4e1d
mod_websocket: Check whether the xmpp sub-protocol was requested
| author | Florian Zeitz <florob@babelmonkeys.de> |
|---|---|
| date | Fri, 05 Oct 2012 19:44:23 +0200 |
| parent | 842:32df4d13f178 |
| child | 849:6e2ec1825182 |
comparison
equal
deleted
inserted
replaced
| 843:cdc67f4efde2 | 844:a0987c0e4e1d |
|---|---|
| 444 return [[<!DOCTYPE html><html><head><title>Websocket</title></head><body> | 444 return [[<!DOCTYPE html><html><head><title>Websocket</title></head><body> |
| 445 <p>It works! Now point your WebSocket client to this URL to connect to Prosody.</p> | 445 <p>It works! Now point your WebSocket client to this URL to connect to Prosody.</p> |
| 446 </body></html>]]; | 446 </body></html>]]; |
| 447 end | 447 end |
| 448 | 448 |
| 449 -- TODO: Handle requested subprotocols | 449 local wants_xmpp = false; |
| 450 (request.headers.sec_websocket_protocol or ""):gsub("([^,]*),?", function (proto) | |
| 451 if proto == "xmpp" then wants_xmpp = true; end | |
| 452 end); | |
| 453 | |
| 454 if not wants_xmpp then | |
| 455 return 501; | |
| 456 end | |
| 450 | 457 |
| 451 response.conn:setlistener(listener); | 458 response.conn:setlistener(listener); |
| 452 response.status = "101 Switching Protocols"; | 459 response.status = "101 Switching Protocols"; |
| 453 response.headers.Upgrade = "websocket"; | 460 response.headers.Upgrade = "websocket"; |
| 454 response.headers.Connection = "Upgrade"; | 461 response.headers.Connection = "Upgrade"; |