Permalink
Browse files

sockjs/sockjs-node#50 - experimental support for sending fake Origin …

…header
  • Loading branch information...
1 parent 9558c8d commit 12d5b72970ca7dca121bfc12c041bc31e4437a9b @majek majek committed Mar 26, 2012
Showing with 7 additions and 2 deletions.
  1. +2 −1 lib/dom2.js
  2. +3 −0 lib/trans-receiver-eventsource.js
  3. +2 −1 lib/trans-receiver-htmlfile.js
View
@@ -99,7 +99,8 @@ var XHRLocalObject = utils.XHRLocalObject = function(method, url, payload) {
var that = this;
utils.delay(function(){
that._start(method, url, payload, {
- no_credentials: true
+ no_credentials: true,
+ headers: {'X-SockJS-Origin': utils.parent_origin || 'null'}
});
});
};
@@ -1,6 +1,9 @@
var EventSourceReceiver = function(url) {
var that = this;
+ url += ((url.indexOf('?') === -1) ? '?' : '&') +
+ 'origin=' + encodeURIComponent(utils.parent_origin || '');
+
var es = new EventSource(url);
es.onmessage = function(e) {
that.dispatchEvent(new SimpleEvent('message',
@@ -19,7 +19,8 @@ var HtmlfileReceiver = function(url) {
that.id = 'a' + utils.random_string(6, 26);
url += ((url.indexOf('?') === -1) ? '?' : '&') +
- 'c=' + escape(WPrefix + '.' + that.id);
+ 'c=' + escape(WPrefix + '.' + that.id) +
+ '&origin=' + encodeURIComponent(utils.parent_origin || '');
var constructor = isIeHtmlfileCapable() ?
utils.createHtmlfile : utils.createIframe;

0 comments on commit 12d5b72

Please sign in to comment.