ming_node 2.9.5 → 2.9.6
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +8 -6
- package/package.json +1 -1
package/index.js
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
* By : Minglie
|
4
4
|
* QQ: 934031452
|
5
5
|
* Date :2021.12.01
|
6
|
-
* version :2.9.
|
6
|
+
* version :2.9.6
|
7
7
|
*/
|
8
8
|
var http = require('http');
|
9
9
|
var https = require('https');
|
@@ -109,7 +109,7 @@ M.get = function (url, callback, data, headers) {
|
|
109
109
|
if (typeof callback == "function") {
|
110
110
|
|
111
111
|
} else {
|
112
|
-
headers = data || {};
|
112
|
+
headers = data || {'Content-Type': 'application/json'};
|
113
113
|
data = callback;
|
114
114
|
callback = () => {
|
115
115
|
};
|
@@ -175,7 +175,11 @@ M.get = function (url, callback, data, headers) {
|
|
175
175
|
res.on('end', function () {
|
176
176
|
callback(html, res);
|
177
177
|
try {
|
178
|
-
|
178
|
+
if(headers && headers['Content-Type']=='application/json'){
|
179
|
+
html = JSON.parse(html)
|
180
|
+
}else {
|
181
|
+
html = html;
|
182
|
+
}
|
179
183
|
} catch (e) {
|
180
184
|
html = html;
|
181
185
|
}
|
@@ -1985,8 +1989,6 @@ M.server = function () {
|
|
1985
1989
|
console.log("listen on port:" + port);
|
1986
1990
|
return server;
|
1987
1991
|
}
|
1988
|
-
|
1989
|
-
global.app=app;
|
1990
1992
|
return app;
|
1991
1993
|
}
|
1992
1994
|
M["_gloable_exception_handle"]=(err)=>{
|
@@ -2833,7 +2835,7 @@ M.getRemoteCacheByUrl = async function (url) {
|
|
2833
2835
|
if (url.startsWith("file:")) {
|
2834
2836
|
text = M.readFile(url.substring(5));
|
2835
2837
|
} else {
|
2836
|
-
text = await M.get(url);
|
2838
|
+
text = await M.get(url,{},{});
|
2837
2839
|
}
|
2838
2840
|
console.log("req remote url:", url);
|
2839
2841
|
M._globle_cacheMap[url] = text;
|
package/package.json
CHANGED