mm_https 1.4.8 → 1.4.9
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 +5 -7
- package/package.json +1 -1
- package/test.js +6 -6
package/index.js
CHANGED
|
@@ -15,9 +15,6 @@ const iconv = require('iconv-lite');
|
|
|
15
15
|
const {
|
|
16
16
|
hostname
|
|
17
17
|
} = require('os');
|
|
18
|
-
const {
|
|
19
|
-
header
|
|
20
|
-
} = require('request/lib/hawk');
|
|
21
18
|
const {
|
|
22
19
|
HttpsProxyAgent
|
|
23
20
|
} = require('https-proxy-agent');
|
|
@@ -71,8 +68,7 @@ Http.prototype.set_cookie = function(cookieStr) {
|
|
|
71
68
|
Http.prototype.get_cookie = function() {
|
|
72
69
|
var dist = this.cookies;
|
|
73
70
|
var str = "";
|
|
74
|
-
for(var k in dist)
|
|
75
|
-
{
|
|
71
|
+
for (var k in dist) {
|
|
76
72
|
str += "; " + k + "=" + dist[k];
|
|
77
73
|
}
|
|
78
74
|
return str;
|
|
@@ -108,7 +104,7 @@ Http.prototype.http_options = function(options) {
|
|
|
108
104
|
// 移除主机地址,取路由路径
|
|
109
105
|
u = u.replace(hostname, "");
|
|
110
106
|
var path = u;
|
|
111
|
-
if(cookie){
|
|
107
|
+
if (cookie) {
|
|
112
108
|
this.set_cookie(cookie);
|
|
113
109
|
}
|
|
114
110
|
return {
|
|
@@ -210,7 +206,9 @@ Http.prototype.request = function(options) {
|
|
|
210
206
|
var body = '';
|
|
211
207
|
var req = hp.request(options, (res) => {
|
|
212
208
|
if (res.statusCode == 200) {
|
|
213
|
-
var {
|
|
209
|
+
var {
|
|
210
|
+
headers
|
|
211
|
+
} = res;
|
|
214
212
|
var buffer = '';
|
|
215
213
|
var encoding = headers['content-encoding'];
|
|
216
214
|
if (encoding) {
|
package/package.json
CHANGED
package/test.js
CHANGED
|
@@ -93,11 +93,11 @@ var fs = require("fs");
|
|
|
93
93
|
// // console.log('结果:', hp.cookies);
|
|
94
94
|
// }
|
|
95
95
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
96
|
+
async function test () {
|
|
97
|
+
var hp = new Http();
|
|
98
|
+
var res = await hp.get('http://www.hao123.com');
|
|
99
|
+
console.log(res.body);
|
|
100
|
+
}
|
|
101
101
|
|
|
102
102
|
// async function test() {
|
|
103
103
|
// var hp = new Http();
|
|
@@ -187,4 +187,4 @@ var fs = require("fs");
|
|
|
187
187
|
// // console.log("结果", res.body);
|
|
188
188
|
// }
|
|
189
189
|
|
|
190
|
-
|
|
190
|
+
test();
|