commit 8820e124b67b9861e33bda98cf97464247bbba22
Author: David Fifield <david(a)bamsoftware.com>
Date: Wed Apr 4 23:27:46 2012 -0700
Move WebSocket || MozWebSocket to global scope.
---
flashproxy.js | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/flashproxy.js b/flashproxy.js
index 10ed935..b7f339b 100644
--- a/flashproxy.js
+++ b/flashproxy.js
@@ -66,6 +66,10 @@ var DEFAULT_RATE_LIMIT = undefined;
var MIN_RATE_LIMIT = 10 * 1024;
var …
[View More]RATE_LIMIT_HISTORY = 5.0;
+/* Gecko browsers use the name MozWebSocket. Also we can test whether WebSocket
+ is defined to see if WebSockets are supported at all. */
+var WebSocket = window.WebSocket || window.MozWebSocket;
+
var query = parse_query_string(window.location.search.substr(1));
var debug_div;
@@ -266,14 +270,11 @@ function have_websocket_binary_frames()
function make_websocket(addr)
{
var url;
- var WebSocket;
var ws;
url = "ws://" + encodeURIComponent(addr.host)
+ ":" + encodeURIComponent(addr.port) + "/";
- WebSocket = window.WebSocket || window.MozWebSocket;
-
if (have_websocket_binary_frames())
ws = new WebSocket(url);
else
[View Less]
commit 7be603c856de465225936a5ed443ce69b69b5f16
Author: David Fifield <david(a)bamsoftware.com>
Date: Wed Apr 4 23:13:19 2012 -0700
Don't use "base64" WebSockets when we don't have to.
Currently it's assumed that binary frames never work, so this doesn't
effectively change anything.
---
flashproxy.js | 24 +++++++++++++++++++++++-
1 files changed, 23 insertions(+), 1 deletions(-)
diff --git a/flashproxy.js b/flashproxy.js
index 25f23fb..10ed935 100644
--- a/…
[View More]flashproxy.js
+++ b/flashproxy.js
@@ -255,14 +255,36 @@ function format_addr(addr)
return addr.host + ":" + addr.port;
}
+/* Does the WebSocket implementation in this browser support binary frames? (RFC
+ 6455 section 5.6.) If not, we have to use base64-encoded text frames. It is
+ assumed that the client and relay endpoints always support binary frames. */
+function have_websocket_binary_frames()
+{
+ return false;
+}
+
function make_websocket(addr)
{
var url;
+ var WebSocket;
+ var ws;
url = "ws://" + encodeURIComponent(addr.host)
+ ":" + encodeURIComponent(addr.port) + "/";
- return new (window.WebSocket || window.MozWebSocket)(url, "base64");
+ WebSocket = window.WebSocket || window.MozWebSocket;
+
+ if (have_websocket_binary_frames())
+ ws = new WebSocket(url);
+ else
+ ws = new WebSocket(url, "base64");
+ /* "User agents can use this as a hint for how to handle incoming binary
+ data: if the attribute is set to 'blob', it is safe to spool it to disk,
+ and if it is set to 'arraybuffer', it is likely more efficient to keep
+ the data in memory." */
+ ws.binaryType = "arraybuffer";
+
+ return ws;
}
function FlashProxy()
[View Less]
commit 48b68ca38541bb5204b04021f48d0e013413d2b0
Author: David Fifield <david(a)bamsoftware.com>
Date: Wed Apr 4 23:28:05 2012 -0700
Always disable on Safari.
Safari only supports the old hixie style of WebSockets. The client
connector isn't compatible with that style. It should be made
compatible, but in the meantime this will prevent Safari from poaching
clients from the facilitator when it can't serve them.
---
flashproxy.js | 3 +++
1 files changed, 3 …
[View More]insertions(+), 0 deletions(-)
diff --git a/flashproxy.js b/flashproxy.js
index b7f339b..235ffbb 100644
--- a/flashproxy.js
+++ b/flashproxy.js
@@ -772,6 +772,9 @@ function flashproxy_should_disable()
/\bmobile\b/i,
/\bandroid\b/i,
/\bopera mobi\b/i,
+ /* Disable on Safari because it doesn't have the hybi/RFC type of
+ WebSockets. */
+ /\bsafari\b/i,
];
for (var i = 0; i < UA_LIST.length; i++) {
[View Less]