comparison mod_http_altconnect/mod_http_altconnect.lua @ 1289:1f15cc58bb56

mod_http_altconnect: Correct module name in HTTP path lookup for websockets
author Kim Alvefur <zash@zash.se>
date Sat, 25 Jan 2014 20:08:10 +0100
parents 27de4109b7e9
children c0957b904487
comparison
equal deleted inserted replaced
1288:c1a8ce147885 1289:1f15cc58bb56
12 local xrd = st.stanza("XRD", { xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0' }); 12 local xrd = st.stanza("XRD", { xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0' });
13 if host_modules["bosh"] then 13 if host_modules["bosh"] then
14 xrd:tag("Link", { rel="urn:xmpp:altconnect:bosh", href = module:http_url("bosh", "/http-bind") }):up(); 14 xrd:tag("Link", { rel="urn:xmpp:altconnect:bosh", href = module:http_url("bosh", "/http-bind") }):up();
15 end 15 end
16 if host_modules["websocket"] then 16 if host_modules["websocket"] then
17 xrd:tag("Link", { rel="urn:xmpp:altconnect:websocket", href = module:http_url("bosh", "/xmpp-websocket"):gsub("^http", "ws") }):up(); 17 xrd:tag("Link", { rel="urn:xmpp:altconnect:websocket", href = module:http_url("websocket", "/xmpp-websocket"):gsub("^http", "ws") }):up();
18 end 18 end
19 response.headers.content_type = "application/xrd+xml" 19 response.headers.content_type = "application/xrd+xml"
20 response.headers.access_control_allow_origin = "*"; 20 response.headers.access_control_allow_origin = "*";
21 return tostring(xrd); 21 return tostring(xrd);
22 end 22 end
26 local jrd = { links = { } }; 26 local jrd = { links = { } };
27 if host_modules["bosh"] then 27 if host_modules["bosh"] then
28 jrd.links[#jrd.links+1] = { rel="urn:xmpp:altconnect:bosh", href = module:http_url("bosh", "/http-bind") }; 28 jrd.links[#jrd.links+1] = { rel="urn:xmpp:altconnect:bosh", href = module:http_url("bosh", "/http-bind") };
29 end 29 end
30 if host_modules["websocket"] then 30 if host_modules["websocket"] then
31 jrd.links[#jrd.links+1] = { rel="urn:xmpp:altconnect:websocket", href = module:http_url("bosh", "/xmpp-websocket"):gsub("^http", "ws") } 31 jrd.links[#jrd.links+1] = { rel="urn:xmpp:altconnect:websocket", href = module:http_url("websocket", "/xmpp-websocket"):gsub("^http", "ws") }
32 end 32 end
33 response.headers.content_type = "application/json" 33 response.headers.content_type = "application/json"
34 response.headers.access_control_allow_origin = "*"; 34 response.headers.access_control_allow_origin = "*";
35 return json.encode(jrd); 35 return json.encode(jrd);
36 end; 36 end;