Software /
code /
prosody
Comparison
plugins/mod_bosh.lua @ 5667:0bf1cdea43f6
mod_bosh: Reduce a little code.
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Tue, 11 Jun 2013 12:55:47 -0400 |
parent | 5660:df077bc8f019 |
child | 5674:ebdbf4cf0b2f |
comparison
equal
deleted
inserted
replaced
5666:c1e1b265ee82 | 5667:0bf1cdea43f6 |
---|---|
35 local bosh_max_wait = module:get_option_number("bosh_max_wait", 120); | 35 local bosh_max_wait = module:get_option_number("bosh_max_wait", 120); |
36 | 36 |
37 local consider_bosh_secure = module:get_option_boolean("consider_bosh_secure"); | 37 local consider_bosh_secure = module:get_option_boolean("consider_bosh_secure"); |
38 local cross_domain = module:get_option("cross_domain_bosh", false); | 38 local cross_domain = module:get_option("cross_domain_bosh", false); |
39 | 39 |
40 if cross_domain == true then cross_domain = "*"; end | |
40 if type(cross_domain) == "table" then cross_domain = table.concat(cross_domain, ", "); end | 41 if type(cross_domain) == "table" then cross_domain = table.concat(cross_domain, ", "); end |
41 | 42 |
42 local trusted_proxies = module:get_option_set("trusted_proxies", {"127.0.0.1"})._items; | 43 local trusted_proxies = module:get_option_set("trusted_proxies", {"127.0.0.1"})._items; |
43 | 44 |
44 local function get_ip_from_request(request) | 45 local function get_ip_from_request(request) |
88 local function set_cross_domain_headers(response) | 89 local function set_cross_domain_headers(response) |
89 local headers = response.headers; | 90 local headers = response.headers; |
90 headers.access_control_allow_methods = "GET, POST, OPTIONS"; | 91 headers.access_control_allow_methods = "GET, POST, OPTIONS"; |
91 headers.access_control_allow_headers = "Content-Type"; | 92 headers.access_control_allow_headers = "Content-Type"; |
92 headers.access_control_max_age = "7200"; | 93 headers.access_control_max_age = "7200"; |
93 | 94 headers.access_control_allow_origin = cross_domain; |
94 if cross_domain == true then | |
95 headers.access_control_allow_origin = "*"; | |
96 else | |
97 headers.access_control_allow_origin = cross_domain; | |
98 end | |
99 return response; | 95 return response; |
100 end | 96 end |
101 | 97 |
102 function handle_OPTIONS(event) | 98 function handle_OPTIONS(event) |
103 if cross_domain and event.request.headers.origin then | 99 if cross_domain and event.request.headers.origin then |