142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
-
-
-
|
|| payload instanceof Array)){
payload = JSON.stringify(payload);
opt.contentType = 'application/json';
}
}
const url=[F.repoUrl(uri,opt.urlParams)],
x=new XMLHttpRequest();
if('POST'===opt.method && 'string'===typeof opt.contentType){
x.setRequestHeader('Content-Type',opt.contentType);
}
if('json'===opt.responseType){
/* 'json' is an extension to the supported XHR.responseType
list. We use it as a flag to tell us to JSON.parse()
the response. */
jsonResponse = true;
x.responseType = 'text';
}else{
|
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
+
+
+
|
opt.onload.apply(opt, args);
}catch(e){
opt.onerror(e);
}
};
try{opt.beforesend()}catch(e){/*ignore*/}
x.open(opt.method||'GET', url.join(''), true);
if('POST'===opt.method && 'string'===typeof opt.contentType){
x.setRequestHeader('Content-Type',opt.contentType);
}
x.timeout = +opt.timeout || f.timeout;
if(undefined!==payload) x.send(payload);
else x.send();
return this;
};
window.fossil.fetch.beforesend = function(){};
window.fossil.fetch.aftersend = function(){};
window.fossil.fetch.timeout = 15000/* Default timeout, in ms. */;
|