whistle 2.10.9 → 2.10.10

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.
@@ -143,7 +143,11 @@ function sendReq(options, callback) {
143
143
 
144
144
  var timer, client;
145
145
  var handleCallback = function (err, res) {
146
+ if (timer == null) {
147
+ return;
148
+ }
146
149
  clearTimeout(timer);
150
+ timer = null;
147
151
  if (httpModule) {
148
152
  httpModule = null;
149
153
  callback(err, res);
@@ -249,7 +253,7 @@ function request(options, callback) {
249
253
  handleCallback(err, res, getBody(body, len));
250
254
  }
251
255
  });
252
- res.on('end', function() {
256
+ res.once('end', function() {
253
257
  handleCallback(null, res, getBody(body, len));
254
258
  });
255
259
  };
@@ -325,7 +329,7 @@ function readFile(url, callback) {
325
329
  }
326
330
  });
327
331
  stream.on('error', listener);
328
- stream.on('end', listener);
332
+ stream.once('end', listener);
329
333
  });
330
334
  }
331
335
 
package/lib/util/index.js CHANGED
@@ -967,8 +967,6 @@ function getPath(url, noProtocol) {
967
967
  return url;
968
968
  }
969
969
 
970
- exports.getPath = getPath;
971
-
972
970
  function getFilename(url) {
973
971
  if (typeof url == 'string' && (url = getPath(url).trim())) {
974
972
  var index = url.lastIndexOf('/');
@@ -1489,48 +1487,47 @@ function getRawType(data) {
1489
1487
 
1490
1488
  exports.getRawType = getRawType;
1491
1489
 
1492
- function getContentType(contentType) {
1493
- if (contentType && typeof contentType != 'string') {
1494
- contentType = contentType['content-type'] || contentType.contentType;
1490
+ function getContentType(type) {
1491
+ if (type && typeof type != 'string') {
1492
+ type = type['content-type'] || type.contentType;
1495
1493
  }
1496
- contentType = _getRawType(contentType);
1497
- if (!contentType) {
1494
+ type = _getRawType(type);
1495
+ if (!type) {
1498
1496
  return;
1499
1497
  }
1500
- if (contentType.indexOf('javascript') != -1) {
1498
+ if (type.indexOf('image/') != -1) {
1499
+ return 'IMG';
1500
+ }
1501
+ if (type.indexOf('javascript') != -1) {
1501
1502
  return 'JS';
1502
1503
  }
1503
1504
 
1504
- if (contentType.indexOf('css') != -1) {
1505
+ if (type.indexOf('css') != -1) {
1505
1506
  return 'CSS';
1506
1507
  }
1507
1508
 
1508
- if (contentType.indexOf('html') != -1) {
1509
+ if (type.indexOf('html') != -1) {
1509
1510
  return 'HTML';
1510
1511
  }
1511
1512
 
1512
- if (contentType.indexOf('json') != -1) {
1513
+ if (type.indexOf('json') != -1) {
1513
1514
  return 'JSON';
1514
1515
  }
1515
1516
 
1516
- if (contentType.indexOf('xml') != -1) {
1517
+ if (type.indexOf('xml') != -1) {
1517
1518
  return 'XML';
1518
1519
  }
1519
1520
 
1520
- if (contentType.indexOf('text/') != -1) {
1521
+ if (type.indexOf('text/') != -1) {
1521
1522
  return 'TEXT';
1522
1523
  }
1523
-
1524
- if (contentType.indexOf('image/') != -1) {
1525
- return 'IMG';
1526
- }
1527
1524
  }
1528
1525
 
1529
1526
  exports.getContentType = getContentType;
1530
1527
 
1531
- function isText(contentType) {
1532
- contentType = contentType && getContentType(contentType);
1533
- return contentType && contentType !== 'IMG';
1528
+ function isText(type) {
1529
+ type = type && getContentType(type);
1530
+ return type && type !== 'IMG';
1534
1531
  }
1535
1532
 
1536
1533
  exports.isText = isText;
@@ -1654,7 +1651,7 @@ function getPipeIconvStream(headers) {
1654
1651
  };
1655
1652
 
1656
1653
  res.on('data', resolveCharset);
1657
- res.on('end', resolveCharset);
1654
+ onReadEnd(res, resolveCharset);
1658
1655
  });
1659
1656
 
1660
1657
  pipeStream.addTail(function (src, next) {
@@ -2649,7 +2646,10 @@ exports.getReqId = function (now) {
2649
2646
  };
2650
2647
 
2651
2648
  exports.onSocketEnd = common.onSocketEnd;
2652
- exports.onResEnd = common.onResEnd;
2649
+
2650
+ var onReadEnd = common.onReadEnd;
2651
+ exports.onReadEnd = onReadEnd;
2652
+ exports.onWriteEnd = common.onWriteEnd;
2653
2653
 
2654
2654
  exports.getEmptyRes = function getRes() {
2655
2655
  var res = common.createTransform();
@@ -3623,7 +3623,7 @@ function readOneChunk(stream, callback, timeout) {
3623
3623
  timer = setTimeout(handler, timeout);
3624
3624
  }
3625
3625
  stream.on('data', handler);
3626
- stream.on('end', handler);
3626
+ onReadEnd(stream, handler);
3627
3627
  }
3628
3628
 
3629
3629
  exports.readOneChunk = readOneChunk;
@@ -4031,3 +4031,9 @@ exports.joinBuffer = function(buf, chunk) {
4031
4031
  exports.formatBuffer = function(buf, len) {
4032
4032
  return Array.isArray(buf) ? Buffer.concat(buf, len) : buf;
4033
4033
  };
4034
+
4035
+ exports.endSocket = function (socket) {
4036
+ if (!socket.destroyed && !socket.writableEnded) {
4037
+ socket.end();
4038
+ }
4039
+ };
@@ -6,11 +6,11 @@ function SpeedTransform(options, req) {
6
6
  Transform.call(this);
7
7
  options = options || {};
8
8
  this._req = req;
9
- var value = parseInt((options.speed * 1000) / 8);
9
+ var value = parseInt((options.speed * 1000) / 8, 10);
10
10
  if (value > 0) {
11
11
  this._speed = value;
12
12
  }
13
- if ((value = parseInt(options.delay)) > 0) {
13
+ if ((value = parseInt(options.delay, 10)) > 0) {
14
14
  this._delay = value;
15
15
  }
16
16
  }
@@ -71,15 +71,15 @@ function Parser() {
71
71
  }
72
72
  var data = parseChunk();
73
73
  if (data === false) {
74
- return self.onEnd && self.onEnd();
74
+ return self.onEnd();
75
75
  }
76
76
  if (!data) {
77
77
  if (chunk === false) {
78
78
  return;
79
79
  }
80
- return self.onContinue && self.onContinue();
80
+ return self.onContinue();
81
81
  }
82
- self.onData && self.onData(data);
82
+ self.onData(data);
83
83
  self.write(false);
84
84
  };
85
85
  }
@@ -91,6 +91,7 @@ exports.getDecodeTransform = function () {
91
91
  parser.onEnd = function () {
92
92
  data && trans.push(data);
93
93
  trans.push(null);
94
+ data = null;
94
95
  };
95
96
  parser.onContinue = function () {
96
97
  if (transCb) {
@@ -9,11 +9,11 @@ var DOCTYPE = Buffer.from('<!DOCTYPE html>\r\n');
9
9
  function WhistleTransform(options, req) {
10
10
  Transform.call(this);
11
11
  options = options || {};
12
- var value = parseInt((options.speed * 1000) / 8);
12
+ var value = parseInt((options.speed * 1000) / 8, 10);
13
13
  if (value > 0) {
14
14
  this._speed = value;
15
15
  }
16
- if ((value = parseInt(options.delay)) > 0) {
16
+ if ((value = parseInt(options.delay, 10)) > 0) {
17
17
  this._delay = value;
18
18
  }
19
19
  this._noDoctype = options.noDoctype;
package/lib/util/zlib.js CHANGED
@@ -19,7 +19,7 @@ function zlibBuffer(engine, buffer, callback) {
19
19
  engine.cb = callback;
20
20
  engine.on('data', zlibBufferOnData);
21
21
  engine.on('error', zlibBufferOnError);
22
- engine.on('end', zlibBufferOnEnd);
22
+ engine.once('end', zlibBufferOnEnd);
23
23
  engine.end(buffer);
24
24
  }
25
25
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "whistle",
3
3
  "description": "HTTP, HTTP2, HTTPS, Websocket debugging proxy",
4
- "version": "2.10.9",
4
+ "version": "2.10.10",
5
5
  "dataDirname": ".whistle",
6
6
  "localUIHost": "local.whistlejs.com",
7
7
  "port": 8899,
@@ -75,7 +75,7 @@
75
75
  "docs": "vitepress build docs"
76
76
  },
77
77
  "engines": {
78
- "node": ">= 8.8"
78
+ "node": ">= 14.0.0"
79
79
  },
80
80
  "devDependencies": {
81
81
  "babel-core": "^6.7.6",
@@ -102,7 +102,7 @@
102
102
  "react": "^15.6.2",
103
103
  "react-base16-styling": "^0.5.1",
104
104
  "react-dom": "^15.6.2",
105
- "react-virtualized": "^9.21.2",
105
+ "react-virtualized": "~9.21.2",
106
106
  "request": "^2.74.0",
107
107
  "should": "^13.2.3",
108
108
  "should-http": "^0.1.1",