mythix 2.4.9 → 2.4.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -83,12 +83,18 @@ function nodeRequestHandler(routeName, requestOptions) {
|
|
|
83
83
|
},
|
|
84
84
|
requestOptions,
|
|
85
85
|
extraConfig,
|
|
86
|
-
{
|
|
86
|
+
{
|
|
87
|
+
headers: Utils.cleanObjectProperties(Object.assign(
|
|
88
|
+
{},
|
|
89
|
+
headers,
|
|
90
|
+
Utils.keysToLowerCase(extraConfig.headers || {})
|
|
91
|
+
)),
|
|
92
|
+
},
|
|
87
93
|
);
|
|
88
94
|
|
|
89
95
|
delete options.data;
|
|
90
96
|
|
|
91
|
-
var thisRequest = HTTP.request(options, function(response) {
|
|
97
|
+
var thisRequest = HTTP.request(Utils.cleanObjectProperties(options), function(response) {
|
|
92
98
|
var responseData = Buffer.alloc(0);
|
|
93
99
|
|
|
94
100
|
response.on('data', function(chunk) {
|
|
@@ -172,7 +178,7 @@ function browserRequestHandler(routeName, requestOptions) {
|
|
|
172
178
|
var url = requestOptions.url;
|
|
173
179
|
var data = requestOptions.data;
|
|
174
180
|
var extraConfig = {};
|
|
175
|
-
var headers = Object.assign(
|
|
181
|
+
var headers = Object.assign(Utils.keysToLowerCase(this.defaultHeaders || {}), Utils.keysToLowerCase(requestOptions.headers || {}));
|
|
176
182
|
|
|
177
183
|
if (data) {
|
|
178
184
|
if (!method.match(/^(GET|HEAD)$/i)) {
|
|
@@ -193,12 +199,18 @@ function browserRequestHandler(routeName, requestOptions) {
|
|
|
193
199
|
{ method },
|
|
194
200
|
requestOptions,
|
|
195
201
|
extraConfig,
|
|
196
|
-
{
|
|
202
|
+
{
|
|
203
|
+
headers: Utils.cleanObjectProperties(Object.assign(
|
|
204
|
+
{},
|
|
205
|
+
headers,
|
|
206
|
+
Utils.keysToLowerCase(extraConfig.headers || {})
|
|
207
|
+
)),
|
|
208
|
+
},
|
|
197
209
|
);
|
|
198
210
|
|
|
199
211
|
delete options.data;
|
|
200
212
|
|
|
201
|
-
globalScope.fetch(url, options).then(
|
|
213
|
+
globalScope.fetch(url, Utils.cleanObjectProperties(options)).then(
|
|
202
214
|
function(response) {
|
|
203
215
|
if (typeof requestOptions.responseHandler === 'function')
|
|
204
216
|
return requestOptions.responseHandler(response);
|
|
@@ -271,6 +283,22 @@ function generateUtils() {
|
|
|
271
283
|
return newObj;
|
|
272
284
|
}
|
|
273
285
|
|
|
286
|
+
function cleanObjectProperties(obj) {
|
|
287
|
+
var keys = Object.keys(obj || {});
|
|
288
|
+
var newObj = {};
|
|
289
|
+
|
|
290
|
+
for (var i = 0, il = keys.length; i < il; i++) {
|
|
291
|
+
var key = keys[i];
|
|
292
|
+
var value = obj[key];
|
|
293
|
+
if (value == null || value == '')
|
|
294
|
+
continue;
|
|
295
|
+
|
|
296
|
+
newObj[key] = value;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
return newObj;
|
|
300
|
+
}
|
|
301
|
+
|
|
274
302
|
function injectURLParams(routeName, _options) {
|
|
275
303
|
var options = _options || {};
|
|
276
304
|
var params = options.params || {};
|
|
@@ -299,6 +327,7 @@ function generateUtils() {
|
|
|
299
327
|
isEmpty,
|
|
300
328
|
dataToQueryString,
|
|
301
329
|
keysToLowerCase,
|
|
330
|
+
cleanObjectProperties,
|
|
302
331
|
injectURLParams,
|
|
303
332
|
};
|
|
304
333
|
})();
|
|
@@ -350,11 +379,15 @@ function generateRoutes(_routes, _options) {
|
|
|
350
379
|
contentType = contentType[0];
|
|
351
380
|
|
|
352
381
|
clientOptions = {
|
|
353
|
-
credentials:
|
|
354
|
-
headers: {
|
|
355
|
-
'Content-Type': contentType,
|
|
356
|
-
},
|
|
382
|
+
credentials: 'same-origin',
|
|
357
383
|
};
|
|
384
|
+
|
|
385
|
+
// Don't set content type for multipart/form-data
|
|
386
|
+
if (!(/multipart\/form-data/i).test(contentType)) {
|
|
387
|
+
clientOptions.headers = {
|
|
388
|
+
'Content-Type': contentType,
|
|
389
|
+
};
|
|
390
|
+
}
|
|
358
391
|
}
|
|
359
392
|
|
|
360
393
|
clientOptions = JSON.stringify(clientOptions, (key, value) => {
|