mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-30 05:19:57 +00:00
Revert "Add defaultHeaders flag that controls helpful default heders that can sometimes interfere with apis (#8152)"
This reverts commit 6910be795f
.
This commit is contained in:
parent
47029bac9e
commit
928f3fc413
@ -39,7 +39,6 @@ exports.startup = function() {
|
||||
method: params.method,
|
||||
body: params.body,
|
||||
binary: params.binary,
|
||||
defaultHeaders: params.defaultHeaders,
|
||||
oncompletion: params.oncompletion,
|
||||
onprogress: params.onprogress,
|
||||
bindStatus: params["bind-status"],
|
||||
|
@ -69,7 +69,7 @@ HttpClient.prototype.cancelAllHttpRequests = function() {
|
||||
for(var t=this.requests.length - 1; t--; t>=0) {
|
||||
var requestInfo = this.requests[t];
|
||||
requestInfo.request.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
this.requests = [];
|
||||
this.updateRequestTracker();
|
||||
@ -112,7 +112,6 @@ function HttpClientRequest(options) {
|
||||
this.method = options.method || "GET";
|
||||
this.body = options.body || "";
|
||||
this.binary = options.binary || "";
|
||||
this.defaultHeaders = options.defaultHeaders || true,
|
||||
this.variables = options.variables;
|
||||
var url = options.url;
|
||||
$tw.utils.each(options.queryStrings,function(value,name) {
|
||||
@ -232,7 +231,7 @@ Make an HTTP request. Options are:
|
||||
exports.httpRequest = function(options) {
|
||||
var type = options.type || "GET",
|
||||
url = options.url,
|
||||
headers = options.headers || (options.defaultHeaders ? {accept: "application/json"} : {}),
|
||||
headers = options.headers || {accept: "application/json"},
|
||||
hasHeader = function(targetHeader) {
|
||||
targetHeader = targetHeader.toLowerCase();
|
||||
var result = false;
|
||||
@ -258,7 +257,7 @@ exports.httpRequest = function(options) {
|
||||
if(hasHeader("Content-Type") && ["application/x-www-form-urlencoded","multipart/form-data","text/plain"].indexOf(getHeader["Content-Type"]) === -1) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return true;
|
||||
},
|
||||
returnProp = options.returnProp || "responseText",
|
||||
request = new XMLHttpRequest(),
|
||||
@ -308,10 +307,10 @@ exports.httpRequest = function(options) {
|
||||
request.setRequestHeader(headerTitle,header);
|
||||
});
|
||||
}
|
||||
if(data && !hasHeader("Content-Type") && options.defaultHeaders) {
|
||||
if(data && !hasHeader("Content-Type")) {
|
||||
request.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
|
||||
}
|
||||
if(!hasHeader("X-Requested-With") && !isSimpleRequest(type,headers) && options.defaultHeaders) {
|
||||
if(!hasHeader("X-Requested-With") && !isSimpleRequest(type,headers)) {
|
||||
request.setRequestHeader("X-Requested-With","TiddlyWiki");
|
||||
}
|
||||
// Send data
|
||||
|
@ -19,7 +19,6 @@ The following parameters are used:
|
||||
|method |HTTP method (eg "GET", "POST") |
|
||||
|body |String data to be sent with the request |
|
||||
|binary |<<.from-version "5.3.1">> Set to "yes" to cause the response body to be treated as binary data and returned in base64 format |
|
||||
|defaultHeaders |<<.from-version "5.3.4">> Defaults to true. Set to "false" to prevent default headers from being added. This can be helpful when dealing with apis that restrict header fields. |
|
||||
|query-* |Query string parameters with string values |
|
||||
|header-* |Headers with string values |
|
||||
|password-header-* |Headers with values taken from the password store |
|
||||
|
Loading…
Reference in New Issue
Block a user