@wiajs/request 3.0.33 → 3.0.35
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/dist/request.cjs +103 -99
- package/dist/request.mjs +103 -99
- package/lib/index.js +1 -1
- package/lib/request.js +11 -7
- package/package.json +1 -1
package/dist/request.cjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* wia request v3.0.
|
|
3
|
-
* (c) 2022-
|
|
2
|
+
* wia request v3.0.35
|
|
3
|
+
* (c) 2022-2025 Sibyl Yu and contributors
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
8
|
const stream = require('node:stream');
|
|
9
9
|
const log$2 = require('@wiajs/log');
|
|
10
|
+
const mime = require('mime-types');
|
|
11
|
+
const assert = require('node:assert');
|
|
10
12
|
const http = require('node:http');
|
|
11
13
|
const https = require('node:https');
|
|
12
|
-
const assert = require('node:assert');
|
|
13
14
|
const url = require('node:url');
|
|
14
15
|
const zlib = require('node:zlib');
|
|
15
|
-
const mime = require('mime-types');
|
|
16
16
|
|
|
17
17
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
18
18
|
class ZlibTransform extends stream.Transform {
|
|
@@ -51,6 +51,100 @@ class ZlibTransform extends stream.Transform {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
class Caseless {
|
|
55
|
+
/**
|
|
56
|
+
* @param {*} dict
|
|
57
|
+
*/
|
|
58
|
+
constructor(dict) {
|
|
59
|
+
this.dict = dict || {};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
*
|
|
64
|
+
* @param {*} name
|
|
65
|
+
* @param {*} value
|
|
66
|
+
* @param {*} clobber
|
|
67
|
+
* @returns
|
|
68
|
+
*/
|
|
69
|
+
set(name, value, clobber) {
|
|
70
|
+
if (typeof name === 'object') {
|
|
71
|
+
for (const n of name) {
|
|
72
|
+
this.set(n, name[n], value);
|
|
73
|
+
}
|
|
74
|
+
} else {
|
|
75
|
+
if (typeof clobber === 'undefined') clobber = true;
|
|
76
|
+
const has = this.has(name);
|
|
77
|
+
|
|
78
|
+
if (!clobber && has) this.dict[has] = this.dict[has] + ',' + value;
|
|
79
|
+
else this.dict[has || name] = value;
|
|
80
|
+
return has
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
*
|
|
86
|
+
* @param {string} name
|
|
87
|
+
* @returns
|
|
88
|
+
*/
|
|
89
|
+
has(name) {
|
|
90
|
+
const keys = Object.keys(this.dict);
|
|
91
|
+
name = name.toLowerCase();
|
|
92
|
+
for (let i = 0; i < keys.length; i++) {
|
|
93
|
+
if (keys[i].toLowerCase() === name) return keys[i]
|
|
94
|
+
}
|
|
95
|
+
return false
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
*
|
|
100
|
+
* @param {string} name
|
|
101
|
+
* @returns
|
|
102
|
+
*/
|
|
103
|
+
get(name) {
|
|
104
|
+
name = name.toLowerCase();
|
|
105
|
+
let result;
|
|
106
|
+
let _key;
|
|
107
|
+
const headers = this.dict;
|
|
108
|
+
for (const key of Object.keys(headers)) {
|
|
109
|
+
_key = key.toLowerCase();
|
|
110
|
+
if (name === _key) result = headers[key];
|
|
111
|
+
}
|
|
112
|
+
return result
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
*
|
|
117
|
+
* @param {string} name
|
|
118
|
+
* @returns
|
|
119
|
+
*/
|
|
120
|
+
swap(name) {
|
|
121
|
+
const has = this.has(name);
|
|
122
|
+
if (has === name) return
|
|
123
|
+
if (!has) throw new Error('There is no header than matches "' + name + '"')
|
|
124
|
+
this.dict[name] = this.dict[has];
|
|
125
|
+
delete this.dict[has];
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
*
|
|
130
|
+
* @param {string} name
|
|
131
|
+
* @returns
|
|
132
|
+
*/
|
|
133
|
+
del(name) {
|
|
134
|
+
name = String(name).toLowerCase();
|
|
135
|
+
let deleted = false;
|
|
136
|
+
let changed = 0;
|
|
137
|
+
const dict = this.dict;
|
|
138
|
+
for (const key of Object.keys(this.dict)) {
|
|
139
|
+
if (name === String(key).toLowerCase()) {
|
|
140
|
+
deleted = delete dict[key];
|
|
141
|
+
changed += 1;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return changed === 0 ? true : deleted
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
54
148
|
/**
|
|
55
149
|
* utils for request
|
|
56
150
|
*/
|
|
@@ -350,100 +444,6 @@ const utils = {
|
|
|
350
444
|
noBody,
|
|
351
445
|
};
|
|
352
446
|
|
|
353
|
-
class Caseless {
|
|
354
|
-
/**
|
|
355
|
-
* @param {*} dict
|
|
356
|
-
*/
|
|
357
|
-
constructor(dict) {
|
|
358
|
-
this.dict = dict || {};
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
/**
|
|
362
|
-
*
|
|
363
|
-
* @param {*} name
|
|
364
|
-
* @param {*} value
|
|
365
|
-
* @param {*} clobber
|
|
366
|
-
* @returns
|
|
367
|
-
*/
|
|
368
|
-
set(name, value, clobber) {
|
|
369
|
-
if (typeof name === 'object') {
|
|
370
|
-
for (const n of name) {
|
|
371
|
-
this.set(n, name[n], value);
|
|
372
|
-
}
|
|
373
|
-
} else {
|
|
374
|
-
if (typeof clobber === 'undefined') clobber = true;
|
|
375
|
-
const has = this.has(name);
|
|
376
|
-
|
|
377
|
-
if (!clobber && has) this.dict[has] = this.dict[has] + ',' + value;
|
|
378
|
-
else this.dict[has || name] = value;
|
|
379
|
-
return has
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
/**
|
|
384
|
-
*
|
|
385
|
-
* @param {string} name
|
|
386
|
-
* @returns
|
|
387
|
-
*/
|
|
388
|
-
has(name) {
|
|
389
|
-
const keys = Object.keys(this.dict);
|
|
390
|
-
name = name.toLowerCase();
|
|
391
|
-
for (let i = 0; i < keys.length; i++) {
|
|
392
|
-
if (keys[i].toLowerCase() === name) return keys[i]
|
|
393
|
-
}
|
|
394
|
-
return false
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
/**
|
|
398
|
-
*
|
|
399
|
-
* @param {string} name
|
|
400
|
-
* @returns
|
|
401
|
-
*/
|
|
402
|
-
get(name) {
|
|
403
|
-
name = name.toLowerCase();
|
|
404
|
-
let result;
|
|
405
|
-
let _key;
|
|
406
|
-
const headers = this.dict;
|
|
407
|
-
for (const key of Object.keys(headers)) {
|
|
408
|
-
_key = key.toLowerCase();
|
|
409
|
-
if (name === _key) result = headers[key];
|
|
410
|
-
}
|
|
411
|
-
return result
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
/**
|
|
415
|
-
*
|
|
416
|
-
* @param {string} name
|
|
417
|
-
* @returns
|
|
418
|
-
*/
|
|
419
|
-
swap(name) {
|
|
420
|
-
const has = this.has(name);
|
|
421
|
-
if (has === name) return
|
|
422
|
-
if (!has) throw new Error('There is no header than matches "' + name + '"')
|
|
423
|
-
this.dict[name] = this.dict[has];
|
|
424
|
-
delete this.dict[has];
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
/**
|
|
428
|
-
*
|
|
429
|
-
* @param {string} name
|
|
430
|
-
* @returns
|
|
431
|
-
*/
|
|
432
|
-
del(name) {
|
|
433
|
-
name = String(name).toLowerCase();
|
|
434
|
-
let deleted = false;
|
|
435
|
-
let changed = 0;
|
|
436
|
-
const dict = this.dict;
|
|
437
|
-
for (const key of Object.keys(this.dict)) {
|
|
438
|
-
if (name === String(key).toLowerCase()) {
|
|
439
|
-
deleted = delete dict[key];
|
|
440
|
-
changed += 1;
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
return changed === 0 ? true : deleted
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
|
|
447
447
|
/**
|
|
448
448
|
* fork from follow-redirects
|
|
449
449
|
* https://github.com/follow-redirects/follow-redirects
|
|
@@ -776,6 +776,8 @@ class Request extends stream.Duplex {
|
|
|
776
776
|
protocol =
|
|
777
777
|
agents.http.proxy && !agents.http.tunnel ? agents.http.proxy.protocol : protocol;
|
|
778
778
|
}
|
|
779
|
+
|
|
780
|
+
// log({scheme, agents, protocol}, 'request')
|
|
779
781
|
}
|
|
780
782
|
|
|
781
783
|
const httpModule = httpModules[protocol];
|
|
@@ -784,6 +786,8 @@ class Request extends stream.Duplex {
|
|
|
784
786
|
// log({opt, protocol}, 'request')
|
|
785
787
|
// Create the native request and set up its event handlers
|
|
786
788
|
// @ts-ignore
|
|
789
|
+
|
|
790
|
+
log$1({httpModule, opt}, 'request');
|
|
787
791
|
const req = httpModule.request(opt, m._onResponse);
|
|
788
792
|
m._currentRequest = req;
|
|
789
793
|
// @ts-ignore
|
|
@@ -1777,7 +1781,7 @@ function request(uri, opts, callback) {
|
|
|
1777
1781
|
try {
|
|
1778
1782
|
// @ts-ignore
|
|
1779
1783
|
const {opt, cb} = init(uri, opts, callback);
|
|
1780
|
-
// log
|
|
1784
|
+
// log({uri, opt, opts}, 'request')
|
|
1781
1785
|
|
|
1782
1786
|
const {data, stream} = opt;
|
|
1783
1787
|
// data 在本函数完成处理,不传递到 request
|
package/dist/request.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* wia request v3.0.
|
|
3
|
-
* (c) 2022-
|
|
2
|
+
* wia request v3.0.35
|
|
3
|
+
* (c) 2022-2025 Sibyl Yu and contributors
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
import stream, { Duplex } from 'node:stream';
|
|
7
7
|
import { log as log$2, name } from '@wiajs/log';
|
|
8
|
+
import mime from 'mime-types';
|
|
9
|
+
import assert from 'node:assert';
|
|
8
10
|
import http from 'node:http';
|
|
9
11
|
import https from 'node:https';
|
|
10
|
-
import assert from 'node:assert';
|
|
11
12
|
import url from 'node:url';
|
|
12
13
|
import zlib from 'node:zlib';
|
|
13
|
-
import mime from 'mime-types';
|
|
14
14
|
|
|
15
15
|
class ZlibTransform extends stream.Transform {
|
|
16
16
|
/**
|
|
@@ -48,6 +48,100 @@ class ZlibTransform extends stream.Transform {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
class Caseless {
|
|
52
|
+
/**
|
|
53
|
+
* @param {*} dict
|
|
54
|
+
*/
|
|
55
|
+
constructor(dict) {
|
|
56
|
+
this.dict = dict || {};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
*
|
|
61
|
+
* @param {*} name
|
|
62
|
+
* @param {*} value
|
|
63
|
+
* @param {*} clobber
|
|
64
|
+
* @returns
|
|
65
|
+
*/
|
|
66
|
+
set(name, value, clobber) {
|
|
67
|
+
if (typeof name === 'object') {
|
|
68
|
+
for (const n of name) {
|
|
69
|
+
this.set(n, name[n], value);
|
|
70
|
+
}
|
|
71
|
+
} else {
|
|
72
|
+
if (typeof clobber === 'undefined') clobber = true;
|
|
73
|
+
const has = this.has(name);
|
|
74
|
+
|
|
75
|
+
if (!clobber && has) this.dict[has] = this.dict[has] + ',' + value;
|
|
76
|
+
else this.dict[has || name] = value;
|
|
77
|
+
return has
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
*
|
|
83
|
+
* @param {string} name
|
|
84
|
+
* @returns
|
|
85
|
+
*/
|
|
86
|
+
has(name) {
|
|
87
|
+
const keys = Object.keys(this.dict);
|
|
88
|
+
name = name.toLowerCase();
|
|
89
|
+
for (let i = 0; i < keys.length; i++) {
|
|
90
|
+
if (keys[i].toLowerCase() === name) return keys[i]
|
|
91
|
+
}
|
|
92
|
+
return false
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
*
|
|
97
|
+
* @param {string} name
|
|
98
|
+
* @returns
|
|
99
|
+
*/
|
|
100
|
+
get(name) {
|
|
101
|
+
name = name.toLowerCase();
|
|
102
|
+
let result;
|
|
103
|
+
let _key;
|
|
104
|
+
const headers = this.dict;
|
|
105
|
+
for (const key of Object.keys(headers)) {
|
|
106
|
+
_key = key.toLowerCase();
|
|
107
|
+
if (name === _key) result = headers[key];
|
|
108
|
+
}
|
|
109
|
+
return result
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
*
|
|
114
|
+
* @param {string} name
|
|
115
|
+
* @returns
|
|
116
|
+
*/
|
|
117
|
+
swap(name) {
|
|
118
|
+
const has = this.has(name);
|
|
119
|
+
if (has === name) return
|
|
120
|
+
if (!has) throw new Error('There is no header than matches "' + name + '"')
|
|
121
|
+
this.dict[name] = this.dict[has];
|
|
122
|
+
delete this.dict[has];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
*
|
|
127
|
+
* @param {string} name
|
|
128
|
+
* @returns
|
|
129
|
+
*/
|
|
130
|
+
del(name) {
|
|
131
|
+
name = String(name).toLowerCase();
|
|
132
|
+
let deleted = false;
|
|
133
|
+
let changed = 0;
|
|
134
|
+
const dict = this.dict;
|
|
135
|
+
for (const key of Object.keys(this.dict)) {
|
|
136
|
+
if (name === String(key).toLowerCase()) {
|
|
137
|
+
deleted = delete dict[key];
|
|
138
|
+
changed += 1;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return changed === 0 ? true : deleted
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
51
145
|
/**
|
|
52
146
|
* utils for request
|
|
53
147
|
*/
|
|
@@ -347,100 +441,6 @@ const utils = {
|
|
|
347
441
|
noBody,
|
|
348
442
|
};
|
|
349
443
|
|
|
350
|
-
class Caseless {
|
|
351
|
-
/**
|
|
352
|
-
* @param {*} dict
|
|
353
|
-
*/
|
|
354
|
-
constructor(dict) {
|
|
355
|
-
this.dict = dict || {};
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
/**
|
|
359
|
-
*
|
|
360
|
-
* @param {*} name
|
|
361
|
-
* @param {*} value
|
|
362
|
-
* @param {*} clobber
|
|
363
|
-
* @returns
|
|
364
|
-
*/
|
|
365
|
-
set(name, value, clobber) {
|
|
366
|
-
if (typeof name === 'object') {
|
|
367
|
-
for (const n of name) {
|
|
368
|
-
this.set(n, name[n], value);
|
|
369
|
-
}
|
|
370
|
-
} else {
|
|
371
|
-
if (typeof clobber === 'undefined') clobber = true;
|
|
372
|
-
const has = this.has(name);
|
|
373
|
-
|
|
374
|
-
if (!clobber && has) this.dict[has] = this.dict[has] + ',' + value;
|
|
375
|
-
else this.dict[has || name] = value;
|
|
376
|
-
return has
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
/**
|
|
381
|
-
*
|
|
382
|
-
* @param {string} name
|
|
383
|
-
* @returns
|
|
384
|
-
*/
|
|
385
|
-
has(name) {
|
|
386
|
-
const keys = Object.keys(this.dict);
|
|
387
|
-
name = name.toLowerCase();
|
|
388
|
-
for (let i = 0; i < keys.length; i++) {
|
|
389
|
-
if (keys[i].toLowerCase() === name) return keys[i]
|
|
390
|
-
}
|
|
391
|
-
return false
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
/**
|
|
395
|
-
*
|
|
396
|
-
* @param {string} name
|
|
397
|
-
* @returns
|
|
398
|
-
*/
|
|
399
|
-
get(name) {
|
|
400
|
-
name = name.toLowerCase();
|
|
401
|
-
let result;
|
|
402
|
-
let _key;
|
|
403
|
-
const headers = this.dict;
|
|
404
|
-
for (const key of Object.keys(headers)) {
|
|
405
|
-
_key = key.toLowerCase();
|
|
406
|
-
if (name === _key) result = headers[key];
|
|
407
|
-
}
|
|
408
|
-
return result
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
/**
|
|
412
|
-
*
|
|
413
|
-
* @param {string} name
|
|
414
|
-
* @returns
|
|
415
|
-
*/
|
|
416
|
-
swap(name) {
|
|
417
|
-
const has = this.has(name);
|
|
418
|
-
if (has === name) return
|
|
419
|
-
if (!has) throw new Error('There is no header than matches "' + name + '"')
|
|
420
|
-
this.dict[name] = this.dict[has];
|
|
421
|
-
delete this.dict[has];
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
/**
|
|
425
|
-
*
|
|
426
|
-
* @param {string} name
|
|
427
|
-
* @returns
|
|
428
|
-
*/
|
|
429
|
-
del(name) {
|
|
430
|
-
name = String(name).toLowerCase();
|
|
431
|
-
let deleted = false;
|
|
432
|
-
let changed = 0;
|
|
433
|
-
const dict = this.dict;
|
|
434
|
-
for (const key of Object.keys(this.dict)) {
|
|
435
|
-
if (name === String(key).toLowerCase()) {
|
|
436
|
-
deleted = delete dict[key];
|
|
437
|
-
changed += 1;
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
return changed === 0 ? true : deleted
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
|
|
444
444
|
/**
|
|
445
445
|
* fork from follow-redirects
|
|
446
446
|
* https://github.com/follow-redirects/follow-redirects
|
|
@@ -773,6 +773,8 @@ class Request extends Duplex {
|
|
|
773
773
|
protocol =
|
|
774
774
|
agents.http.proxy && !agents.http.tunnel ? agents.http.proxy.protocol : protocol;
|
|
775
775
|
}
|
|
776
|
+
|
|
777
|
+
// log({scheme, agents, protocol}, 'request')
|
|
776
778
|
}
|
|
777
779
|
|
|
778
780
|
const httpModule = httpModules[protocol];
|
|
@@ -781,6 +783,8 @@ class Request extends Duplex {
|
|
|
781
783
|
// log({opt, protocol}, 'request')
|
|
782
784
|
// Create the native request and set up its event handlers
|
|
783
785
|
// @ts-ignore
|
|
786
|
+
|
|
787
|
+
log$1({httpModule, opt}, 'request');
|
|
784
788
|
const req = httpModule.request(opt, m._onResponse);
|
|
785
789
|
m._currentRequest = req;
|
|
786
790
|
// @ts-ignore
|
|
@@ -1774,7 +1778,7 @@ function request(uri, opts, callback) {
|
|
|
1774
1778
|
try {
|
|
1775
1779
|
// @ts-ignore
|
|
1776
1780
|
const {opt, cb} = init(uri, opts, callback);
|
|
1777
|
-
// log
|
|
1781
|
+
// log({uri, opt, opts}, 'request')
|
|
1778
1782
|
|
|
1779
1783
|
const {data, stream} = opt;
|
|
1780
1784
|
// data 在本函数完成处理,不传递到 request
|
package/lib/index.js
CHANGED
|
@@ -128,7 +128,7 @@ const log = Log({
|
|
|
128
128
|
try {
|
|
129
129
|
// @ts-ignore
|
|
130
130
|
const { opt, cb } = init(uri, opts, callback);
|
|
131
|
-
// log
|
|
131
|
+
// log({uri, opt, opts}, 'request')
|
|
132
132
|
const { data, stream } = opt;
|
|
133
133
|
// data 在本函数完成处理,不传递到 request
|
|
134
134
|
opt.data = undefined;
|
package/lib/request.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* fork from follow-redirects
|
|
3
3
|
* https://github.com/follow-redirects/follow-redirects
|
|
4
|
-
*/ import
|
|
5
|
-
import
|
|
4
|
+
*/ import { log as Log, name } from '@wiajs/log';
|
|
5
|
+
import mime from 'mime-types';
|
|
6
6
|
import assert from 'node:assert';
|
|
7
|
+
import http from 'node:http';
|
|
8
|
+
import https from 'node:https';
|
|
9
|
+
import stream, { Duplex } from 'node:stream';
|
|
7
10
|
import url from 'node:url';
|
|
8
|
-
import stream from 'node:stream';
|
|
9
|
-
import { Duplex } from 'node:stream'; // Writable 流改为读写双工
|
|
10
11
|
import zlib from 'node:zlib';
|
|
11
|
-
import mime from 'mime-types';
|
|
12
|
-
import { log as Log, name } from '@wiajs/log';
|
|
13
12
|
import ZlibTransform from './ZlibTransform.js';
|
|
14
|
-
import utils from './utils.js';
|
|
15
13
|
import Caseless from './caseless.js';
|
|
14
|
+
import utils from './utils.js';
|
|
16
15
|
const log = Log({
|
|
17
16
|
env: `wia:req:${name(import.meta.url)}`
|
|
18
17
|
}) // __filename
|
|
@@ -259,12 +258,17 @@ const ConnResetError = utils.createErrorType('ERR_CONNRESET', '连接被重置
|
|
|
259
258
|
if (protocol === 'http:' && agents.http) {
|
|
260
259
|
protocol = agents.http.proxy && !agents.http.tunnel ? agents.http.proxy.protocol : protocol;
|
|
261
260
|
}
|
|
261
|
+
// log({scheme, agents, protocol}, 'request')
|
|
262
262
|
}
|
|
263
263
|
const httpModule = httpModules[protocol];
|
|
264
264
|
if (!httpModule) throw TypeError(`Unsupported protocol: ${protocol}`);
|
|
265
265
|
// log({opt, protocol}, 'request')
|
|
266
266
|
// Create the native request and set up its event handlers
|
|
267
267
|
// @ts-ignore
|
|
268
|
+
log({
|
|
269
|
+
httpModule,
|
|
270
|
+
opt
|
|
271
|
+
}, 'request');
|
|
268
272
|
const req = httpModule.request(opt, m._onResponse);
|
|
269
273
|
m._currentRequest = req;
|
|
270
274
|
// @ts-ignore
|
package/package.json
CHANGED