mm_https 1.5.1 → 1.5.2
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 +11 -9
- package/package.json +1 -1
- package/test.js +14 -9
- package/logonew.png +0 -0
package/index.js
CHANGED
|
@@ -38,8 +38,8 @@ class Http {
|
|
|
38
38
|
// 'sec-fetch-mode': 'navigate',
|
|
39
39
|
// 'sec-fetch-site': 'none',
|
|
40
40
|
// 'sec-fetch-user': '?1',
|
|
41
|
-
'Upgrade-Insecure-Requests': '1',
|
|
42
|
-
'
|
|
41
|
+
// 'Upgrade-Insecure-Requests': '1',
|
|
42
|
+
// 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36'
|
|
43
43
|
},
|
|
44
44
|
rejectUnauthorized: false,
|
|
45
45
|
cookie: "",
|
|
@@ -207,13 +207,14 @@ Http.prototype.req = async function(options) {
|
|
|
207
207
|
this.post_option(op);
|
|
208
208
|
}
|
|
209
209
|
var res = await this.request(op);
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
var
|
|
210
|
+
console.log(op);
|
|
211
|
+
if (res.status.code == 302) {
|
|
212
|
+
var url = res.headers.location;
|
|
213
|
+
var lt = res.headers['set-cookie'];
|
|
213
214
|
if (lt) {
|
|
214
215
|
var len = lt.length;
|
|
215
216
|
for (var i = 0; i < len; i++) {
|
|
216
|
-
|
|
217
|
+
this.set_cookie(lt[i]);
|
|
217
218
|
}
|
|
218
219
|
options.href = url;
|
|
219
220
|
op = this.http_options(options);
|
|
@@ -268,10 +269,10 @@ Http.prototype.request = function(options) {
|
|
|
268
269
|
return new Promise(function(resolve, reject) {
|
|
269
270
|
var body = '';
|
|
270
271
|
var req = hp.request(options, (res) => {
|
|
272
|
+
var {
|
|
273
|
+
headers
|
|
274
|
+
} = res;
|
|
271
275
|
if (res.statusCode == 200) {
|
|
272
|
-
var {
|
|
273
|
-
headers
|
|
274
|
-
} = res;
|
|
275
276
|
var chunks = [];
|
|
276
277
|
var encoding = headers['content-encoding'];
|
|
277
278
|
res.on('data', function(d) {
|
|
@@ -308,6 +309,7 @@ Http.prototype.request = function(options) {
|
|
|
308
309
|
});
|
|
309
310
|
} else {
|
|
310
311
|
resolve({
|
|
312
|
+
headers,
|
|
311
313
|
status: {
|
|
312
314
|
code: res.statusCode,
|
|
313
315
|
message: res.statusMessage
|
package/package.json
CHANGED
package/test.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
// const nJwt = require('njwt');
|
|
2
|
-
var http = require('http');
|
|
3
2
|
var Http = require('./index.js');
|
|
4
3
|
var fs = require("fs");
|
|
5
4
|
|
|
5
|
+
async function test(){
|
|
6
|
+
var http = new Http();
|
|
7
|
+
// var res = await http.get("https://www.baidu.com/");
|
|
8
|
+
var res = await http.get("https://www.hao123.com/");
|
|
9
|
+
console.log("html", res);
|
|
10
|
+
}
|
|
11
|
+
|
|
6
12
|
// async function test3() {
|
|
7
13
|
// // 将「微信对话开放平台」得到的信息填入
|
|
8
14
|
// var APPID = "xxx";
|
|
@@ -25,7 +31,6 @@ var fs = require("fs");
|
|
|
25
31
|
// }
|
|
26
32
|
// test3();
|
|
27
33
|
|
|
28
|
-
|
|
29
34
|
// async function test2(content, from_user) {.
|
|
30
35
|
// 图灵机器人
|
|
31
36
|
// const apikey = "xxx";
|
|
@@ -104,13 +109,13 @@ var fs = require("fs");
|
|
|
104
109
|
// }
|
|
105
110
|
|
|
106
111
|
|
|
107
|
-
async function test() {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
112
|
+
// async function test() {
|
|
113
|
+
// var hp = new Http();
|
|
114
|
+
// hp.config.headers.Accept = "application/javascript; charset=UTF-8";
|
|
115
|
+
// var url ="http://localhost:8001/api/wallet/count";
|
|
116
|
+
// var res = await hp.get(url);
|
|
117
|
+
// console.log(res);
|
|
118
|
+
// }
|
|
114
119
|
|
|
115
120
|
// async function test() {
|
|
116
121
|
// console.log("测试")
|
package/logonew.png
DELETED
|
Binary file
|