Skip to content
This repository was archived by the owner on Jan 10, 2024. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions forcetk.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -80,6 +80,17 @@ if (forcetk.Client === undefined) {
this.asyncAjax = true;
};

/**
* Creates an AJAX request object. Can be overridden for particular implementations.
*/
forcetk.Client.prototype.getXHR = function () {
if (window && window.Sarissa && window.Sarissa.originalXMLHttpRequest) {
return new window.Sarissa.originalXMLHttpRequest();
} else {
return new XMLHttpRequest();
}
};

/**
* Set a refresh token in the client.
* @param refreshToken an OAuth refresh token
Expand DownExpand Up@@ -211,7 +222,7 @@ if (forcetk.Client === undefined) {
'use strict';
var that = this,
url = (this.visualforce ? '' : this.instanceUrl) + path,
request = new XMLHttpRequest();
request = this.getXHR();

request.open("GET", (this.proxyUrl !== null && !this.visualforce) ? this.proxyUrl : url, true);
request.responseType = "arraybuffer";
Expand DownExpand Up@@ -290,10 +301,10 @@ if (forcetk.Client === undefined) {
+ "Content-Disposition: form-data; name=\"" + payloadField
+ "\"; filename=\"" + filename + "\"\n\n",
payload,
"\n\n"
"\n"
+ "--boundary_" + boundary + "--"
], {type : 'multipart/form-data; boundary=\"boundary_' + boundary + '\"'}),
request = new XMLHttpRequest();
request = this.getXHR();

request.open("POST", (this.proxyUrl !== null && !this.visualforce) ? this.proxyUrl : url, this.asyncAjax);

Expand Down