1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-16 23:04:50 +00:00

Merge branch 'master' into geospatial-plugin

This commit is contained in:
Jeremy Ruston 2024-05-31 10:28:09 +01:00
commit b0c5f1b547
5 changed files with 17 additions and 12 deletions

View File

@ -1,3 +1,6 @@
title: $:/boot/boot.css
type: text/css
/* /*
Basic styles used before we boot up the parsing engine Basic styles used before we boot up the parsing engine
*/ */

View File

@ -25,11 +25,8 @@
} }
}, },
{ {
"file": "boot.css", "file": "boot.css.tid",
"fields": { "isTiddlerFile": true
"title": "$:/boot/boot.css",
"type": "text/css"
}
} }
] ]
} }

View File

@ -39,6 +39,7 @@ exports.startup = function() {
method: params.method, method: params.method,
body: params.body, body: params.body,
binary: params.binary, binary: params.binary,
useDefaultHeaders: params.useDefaultHeaders,
oncompletion: params.oncompletion, oncompletion: params.oncompletion,
onprogress: params.onprogress, onprogress: params.onprogress,
bindStatus: params["bind-status"], bindStatus: params["bind-status"],
@ -69,8 +70,8 @@ exports.startup = function() {
// Install the copy-to-clipboard mechanism // Install the copy-to-clipboard mechanism
$tw.rootWidget.addEventListener("tm-copy-to-clipboard",function(event) { $tw.rootWidget.addEventListener("tm-copy-to-clipboard",function(event) {
$tw.utils.copyToClipboard(event.param,{ $tw.utils.copyToClipboard(event.param,{
successNotification: event.paramObject.successNotification, successNotification: event.paramObject && event.paramObject.successNotification,
failureNotification: event.paramObject.failureNotification failureNotification: event.paramObject && event.paramObject.failureNotification
}); });
}); });
// Install the tm-focus-selector message // Install the tm-focus-selector message

View File

@ -112,6 +112,7 @@ function HttpClientRequest(options) {
this.method = options.method || "GET"; this.method = options.method || "GET";
this.body = options.body || ""; this.body = options.body || "";
this.binary = options.binary || ""; this.binary = options.binary || "";
this.useDefaultHeaders = options.useDefaultHeaders !== "false" ? true : false,
this.variables = options.variables; this.variables = options.variables;
var url = options.url; var url = options.url;
$tw.utils.each(options.queryStrings,function(value,name) { $tw.utils.each(options.queryStrings,function(value,name) {
@ -156,6 +157,7 @@ HttpClientRequest.prototype.send = function(callback) {
this.xhr = $tw.utils.httpRequest({ this.xhr = $tw.utils.httpRequest({
url: this.url, url: this.url,
type: this.method, type: this.method,
useDefaultHeaders: this.useDefaultHeaders,
headers: this.requestHeaders, headers: this.requestHeaders,
data: this.body, data: this.body,
returnProp: this.binary === "" ? "responseText" : "response", returnProp: this.binary === "" ? "responseText" : "response",
@ -231,7 +233,8 @@ Make an HTTP request. Options are:
exports.httpRequest = function(options) { exports.httpRequest = function(options) {
var type = options.type || "GET", var type = options.type || "GET",
url = options.url, url = options.url,
headers = options.headers || {accept: "application/json"}, useDefaultHeaders = options.useDefaultHeaders !== false ? true : false,
headers = options.headers || (useDefaultHeaders ? {accept: "application/json"} : {}),
hasHeader = function(targetHeader) { hasHeader = function(targetHeader) {
targetHeader = targetHeader.toLowerCase(); targetHeader = targetHeader.toLowerCase();
var result = false; var result = false;
@ -307,10 +310,10 @@ exports.httpRequest = function(options) {
request.setRequestHeader(headerTitle,header); request.setRequestHeader(headerTitle,header);
}); });
} }
if(data && !hasHeader("Content-Type")) { if(data && !hasHeader("Content-Type") && useDefaultHeaders) {
request.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"); request.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
} }
if(!hasHeader("X-Requested-With") && !isSimpleRequest(type,headers)) { if(!hasHeader("X-Requested-With") && !isSimpleRequest(type,headers) && useDefaultHeaders) {
request.setRequestHeader("X-Requested-With","TiddlyWiki"); request.setRequestHeader("X-Requested-With","TiddlyWiki");
} }
// Send data // Send data

View File

@ -19,6 +19,7 @@ The following parameters are used:
|method |HTTP method (eg "GET", "POST") | |method |HTTP method (eg "GET", "POST") |
|body |String data to be sent with the request | |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 | |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 |
|useDefaultHeaders |<<.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 | |query-* |Query string parameters with string values |
|header-* |Headers with string values | |header-* |Headers with string values |
|password-header-* |Headers with values taken from the password store | |password-header-* |Headers with values taken from the password store |