Skip to content

Instantly share code, notes, and snippets.

@bmatusiak
Last active December 16, 2015 01:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bmatusiak/5358707 to your computer and use it in GitHub Desktop.
Save bmatusiak/5358707 to your computer and use it in GitHub Desktop.
/**
* Compatibility layer for Webkit based browsers.
* @private
*/
apf.runWebkit = function(){
if (XMLHttpRequest.prototype.sendAsBinary === undefined) {
if (window.ArrayBuffer) {
/**
* Binary support for Chrome 7+ which implements [ECMA-262] typed arrays
*
* For more information, see <http://www.khronos.org/registry/typedarray/specs/latest/>.
*/
XMLHttpRequest.prototype.sendAsBinary = function(string) {
var bytes = Array.prototype.map.call(string, function(c) {
return c.charCodeAt(0) & 0xff;
});
this.send(new Uint8Array(bytes));
};
}
}
/**
* Compatibility layer for Webkit based browsers.
* @private
*/
apf.runWebkit = function(){
if (XMLHttpRequest.prototype.sendAsBinary === undefined) {
if (window.ArrayBuffer) {
/**
* Binary support for Chrome 7+ which implements [ECMA-262] typed arrays
*
* For more information, see <http://www.khronos.org/registry/typedarray/specs/latest/>.
*/
XMLHttpRequest.prototype.sendAsBinary = function(string) {
var bytes = Array.prototype.map.call(string, function(c) {
return c.charCodeAt(0) & 0xff;
});
this.send(new Uint8Array(bytes).buffer);
};
}
}
@bmatusiak
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment