Software / code / prosody
Comparison
plugins/mod_bosh.lua @ 5654:020c5cd6eb28
mod_bosh: Only return CORS headers if the Origin header is received, and CORS is enabled.
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Fri, 07 Jun 2013 14:20:13 -0400 |
| parent | 5653:c7d10b1a64b1 |
| child | 5658:97c1c1bdd7bc |
comparison
equal
deleted
inserted
replaced
| 5653:c7d10b1a64b1 | 5654:020c5cd6eb28 |
|---|---|
| 98 end | 98 end |
| 99 return response; | 99 return response; |
| 100 end | 100 end |
| 101 | 101 |
| 102 function handle_OPTIONS(event) | 102 function handle_OPTIONS(event) |
| 103 set_cross_domain_headers(event.response); | 103 if cross_domain and event.request.headers.origin then |
| 104 set_cross_domain_headers(event.response); | |
| 105 end | |
| 104 return ""; | 106 return ""; |
| 105 end | 107 end |
| 106 | 108 |
| 107 function handle_POST(event) | 109 function handle_POST(event) |
| 108 log("debug", "Handling new request %s: %s\n----------", tostring(event.request), tostring(event.request.body)); | 110 log("debug", "Handling new request %s: %s\n----------", tostring(event.request), tostring(event.request.body)); |
| 116 response.context = context; | 118 response.context = context; |
| 117 | 119 |
| 118 local headers = response.headers; | 120 local headers = response.headers; |
| 119 headers.content_type = "text/xml; charset=utf-8"; | 121 headers.content_type = "text/xml; charset=utf-8"; |
| 120 | 122 |
| 121 if cross_domain then | 123 if cross_domain and event.request.headers.origin then |
| 122 set_cross_domain_headers(response); | 124 set_cross_domain_headers(response); |
| 123 end | 125 end |
| 124 | 126 |
| 125 -- stream:feed() calls the stream_callbacks, so all stanzas in | 127 -- stream:feed() calls the stream_callbacks, so all stanzas in |
| 126 -- the body are processed in this next line before it returns. | 128 -- the body are processed in this next line before it returns. |