mm_https 1.4.5 → 1.4.6
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/index.js +15 -10
- package/package.json +2 -2
- package/test.js +16 -13
package/index.js
CHANGED
|
@@ -67,14 +67,19 @@ class Http {
|
|
|
67
67
|
|
|
68
68
|
this.config = Object.assign({
|
|
69
69
|
headers: {
|
|
70
|
-
'
|
|
71
|
-
'
|
|
72
|
-
'
|
|
73
|
-
'
|
|
74
|
-
'
|
|
75
|
-
'
|
|
76
|
-
'
|
|
77
|
-
'
|
|
70
|
+
'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
|
|
71
|
+
'accept-encoding': 'gzip, deflate',
|
|
72
|
+
'accept-language': 'zh-CN,zh;q=0.9',
|
|
73
|
+
'cache-control': 'max-age=0',
|
|
74
|
+
'sec-ch-ua': '"Google Chrome";v="95", "Chromium";v="95", ";Not A Brand";v="99"',
|
|
75
|
+
'sec-ch-ua-mobile': '?0',
|
|
76
|
+
'sec-ch-ua-platform': '"Windows"',
|
|
77
|
+
'sec-fetch-dest': 'document',
|
|
78
|
+
'sec-fetch-mode': 'navigate',
|
|
79
|
+
'sec-fetch-site': 'none',
|
|
80
|
+
'sec-fetch-user': '?1',
|
|
81
|
+
'upgrade-insecure-requests': '1',
|
|
82
|
+
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36'
|
|
78
83
|
},
|
|
79
84
|
rejectUnauthorized: false
|
|
80
85
|
}, config)
|
|
@@ -178,7 +183,7 @@ Http.prototype.req = function(options, param) {
|
|
|
178
183
|
}
|
|
179
184
|
resolve({
|
|
180
185
|
headers: res.headers,
|
|
181
|
-
binary:
|
|
186
|
+
binary: decoded,
|
|
182
187
|
body: body
|
|
183
188
|
});
|
|
184
189
|
}
|
|
@@ -195,7 +200,7 @@ Http.prototype.req = function(options, param) {
|
|
|
195
200
|
}
|
|
196
201
|
resolve({
|
|
197
202
|
headers: res.headers,
|
|
198
|
-
binary:
|
|
203
|
+
binary: decoded,
|
|
199
204
|
body: body
|
|
200
205
|
});
|
|
201
206
|
}
|
package/package.json
CHANGED
package/test.js
CHANGED
|
@@ -101,19 +101,22 @@ var fs = require("fs");
|
|
|
101
101
|
// test();
|
|
102
102
|
|
|
103
103
|
|
|
104
|
-
|
|
105
|
-
// var hp = new Http();
|
|
106
|
-
// var url = "https://pic.90tu.com/d/file/update/202005/26/b0lxtps0cpi08.jpg";
|
|
107
|
-
// "./美女/中文".addDir();
|
|
108
|
-
// var file = await hp.download(url, "./美女/中文", true, null, null);
|
|
109
|
-
// console.log(file);
|
|
110
|
-
// }
|
|
111
|
-
|
|
112
|
-
async function test(){
|
|
104
|
+
async function download(){
|
|
113
105
|
var hp = new Http();
|
|
114
|
-
var url = "
|
|
115
|
-
var
|
|
116
|
-
|
|
106
|
+
// var url = "http://www.haoduoma.com/d/file/p/2021-06-18/76df67e451ca9dec9991588ad7fda6e6.jpg";
|
|
107
|
+
var url = "https://www.copipi.com/p/224/224/becce1fc21d723614b598f5377d5d676.jpg";
|
|
108
|
+
"./二维码/中文".addDir();
|
|
109
|
+
var filename = "./二维码/你好.jpg".fullname();
|
|
110
|
+
var file = await hp.download(url, filename);
|
|
111
|
+
console.log(file);
|
|
117
112
|
}
|
|
113
|
+
download();
|
|
114
|
+
|
|
115
|
+
// async function test(){
|
|
116
|
+
// var hp = new Http();
|
|
117
|
+
// var url = "https://weibo.com/p/1003061669879400";
|
|
118
|
+
// var res = await hp.get(url);
|
|
119
|
+
// console.log(res);
|
|
120
|
+
// }
|
|
118
121
|
|
|
119
|
-
test();
|
|
122
|
+
// test();
|