Fossil SCM

JS fossil.fetch(): moved an XHR.setRequestHeader() call to after the XHR.open() call because FF now says it must be done in that order.

stephan 2020-07-09 03:13 trunk
Commit 98f3c05c09ac07cf4ca54a062dd8f64addb132cf3fe52e51507ba70a3757e061
1 file changed +3 -3
--- src/fossil.fetch.js
+++ src/fossil.fetch.js
@@ -144,13 +144,10 @@
144144
opt.contentType = 'application/json';
145145
}
146146
}
147147
const url=[F.repoUrl(uri,opt.urlParams)],
148148
x=new XMLHttpRequest();
149
- if('POST'===opt.method && 'string'===typeof opt.contentType){
150
- x.setRequestHeader('Content-Type',opt.contentType);
151
- }
152149
if('json'===opt.responseType){
153150
/* 'json' is an extension to the supported XHR.responseType
154151
list. We use it as a flag to tell us to JSON.parse()
155152
the response. */
156153
jsonResponse = true;
@@ -195,14 +192,17 @@
195192
opt.onerror(e);
196193
}
197194
};
198195
try{opt.beforesend()}catch(e){/*ignore*/}
199196
x.open(opt.method||'GET', url.join(''), true);
197
+ if('POST'===opt.method && 'string'===typeof opt.contentType){
198
+ x.setRequestHeader('Content-Type',opt.contentType);
199
+ }
200200
x.timeout = +opt.timeout || f.timeout;
201201
if(undefined!==payload) x.send(payload);
202202
else x.send();
203203
return this;
204204
};
205205
206206
window.fossil.fetch.beforesend = function(){};
207207
window.fossil.fetch.aftersend = function(){};
208208
window.fossil.fetch.timeout = 15000/* Default timeout, in ms. */;
209209
--- src/fossil.fetch.js
+++ src/fossil.fetch.js
@@ -144,13 +144,10 @@
144 opt.contentType = 'application/json';
145 }
146 }
147 const url=[F.repoUrl(uri,opt.urlParams)],
148 x=new XMLHttpRequest();
149 if('POST'===opt.method && 'string'===typeof opt.contentType){
150 x.setRequestHeader('Content-Type',opt.contentType);
151 }
152 if('json'===opt.responseType){
153 /* 'json' is an extension to the supported XHR.responseType
154 list. We use it as a flag to tell us to JSON.parse()
155 the response. */
156 jsonResponse = true;
@@ -195,14 +192,17 @@
195 opt.onerror(e);
196 }
197 };
198 try{opt.beforesend()}catch(e){/*ignore*/}
199 x.open(opt.method||'GET', url.join(''), true);
 
 
 
200 x.timeout = +opt.timeout || f.timeout;
201 if(undefined!==payload) x.send(payload);
202 else x.send();
203 return this;
204 };
205
206 window.fossil.fetch.beforesend = function(){};
207 window.fossil.fetch.aftersend = function(){};
208 window.fossil.fetch.timeout = 15000/* Default timeout, in ms. */;
209
--- src/fossil.fetch.js
+++ src/fossil.fetch.js
@@ -144,13 +144,10 @@
144 opt.contentType = 'application/json';
145 }
146 }
147 const url=[F.repoUrl(uri,opt.urlParams)],
148 x=new XMLHttpRequest();
 
 
 
149 if('json'===opt.responseType){
150 /* 'json' is an extension to the supported XHR.responseType
151 list. We use it as a flag to tell us to JSON.parse()
152 the response. */
153 jsonResponse = true;
@@ -195,14 +192,17 @@
192 opt.onerror(e);
193 }
194 };
195 try{opt.beforesend()}catch(e){/*ignore*/}
196 x.open(opt.method||'GET', url.join(''), true);
197 if('POST'===opt.method && 'string'===typeof opt.contentType){
198 x.setRequestHeader('Content-Type',opt.contentType);
199 }
200 x.timeout = +opt.timeout || f.timeout;
201 if(undefined!==payload) x.send(payload);
202 else x.send();
203 return this;
204 };
205
206 window.fossil.fetch.beforesend = function(){};
207 window.fossil.fetch.aftersend = function(){};
208 window.fossil.fetch.timeout = 15000/* Default timeout, in ms. */;
209

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button