whistle 2.10.13 → 2.10.14

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.
@@ -1089,7 +1089,7 @@ function getOptions(req, res, type) {
1089
1089
  options.protocol = 'http:';
1090
1090
  options.host = LOCALHOST;
1091
1091
  options.hostname = null;
1092
- options.agent = false;
1092
+ options.agent = config.localAgent;
1093
1093
 
1094
1094
  return options;
1095
1095
  }
@@ -420,7 +420,6 @@ function sessionsHandler() {
420
420
  });
421
421
  app.post('/cgi-bin/composer', jsonParser, composer.handleRequest);
422
422
  app.get('/cgi-bin/compose-data', handleComposeData);
423
- '';
424
423
  app.get('/cgi-bin/saved/list', function(req, res) {
425
424
  util.getSavedList(SAVED_SESSIONS_PATH, function(err, list) {
426
425
  if (err) {
package/lib/util/drain.js CHANGED
@@ -1,13 +1,23 @@
1
1
  var common = require('./common');
2
2
 
3
+ var createTransform = common.createTransform;
3
4
  var noop = common.noop;
4
- var onReadEnd = common.onReadEnd;
5
5
 
6
6
  module.exports = function (stream, endHandler) {
7
7
  if (stream._hasAlreadyDrain || (!stream.noReqBody && stream.useH2)) {
8
- return typeof endHandler == 'function' && endHandler();
8
+ return endHandler && endHandler();
9
9
  }
10
10
  stream._hasAlreadyDrain = true;
11
- onReadEnd(stream, endHandler);
12
- stream.on('data', noop).on('error', noop);
11
+ // 需要跟 pipeStream 配合使用,确保流的结束事件能够被正确触发,不能直接用 common.onReadEnd
12
+ var emitEndStream = createTransform();
13
+ emitEndStream.on('data', noop).on('error', noop);
14
+ if (endHandler) {
15
+ // 204 + pipe 可能不触发 end 事件,需要手动调用 endHandler
16
+ if (stream.readableEnded) {
17
+ endHandler();
18
+ } else {
19
+ emitEndStream.on('end', endHandler);
20
+ }
21
+ }
22
+ stream.pipe(emitEndStream);
13
23
  };
package/lib/util/index.js CHANGED
@@ -740,7 +740,10 @@ exports.getClientIpList = function() {
740
740
  };
741
741
 
742
742
  exports.addClientIp = function(ip) {
743
- if (clientIpMap.has(ip) && clientIpMap.size > 1) {
743
+ if (clientIpMap.has(ip)) {
744
+ if (clientIpMap.size === 1) {
745
+ return;
746
+ }
744
747
  clientIpMap.delete(ip);
745
748
  }
746
749
  clientIpMap.set(ip, 1);
@@ -2991,7 +2994,7 @@ exports.disableReqProps = function (req) {
2991
2994
  delete headers['user-agent'];
2992
2995
  }
2993
2996
 
2994
- if (disable.gzip || disable.zip || isEnable(req, 'captureStream')) {
2997
+ if (disable.gzip || disable.encoding || disable.zip || isEnable(req, 'captureStream')) {
2995
2998
  delete headers['accept-encoding'];
2996
2999
  }
2997
3000
 
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "whistle",
3
3
  "description": "HTTP, HTTP2, HTTPS, Websocket debugging proxy",
4
- "version": "2.10.13",
4
+ "version": "2.10.14",
5
5
  "dataDirname": ".whistle",
6
6
  "localUIHost": "local.whistlejs.com",
7
7
  "port": 8899,
8
- "sockets": 256,
8
+ "sockets": 96,
9
9
  "timeout": 360000,
10
10
  "author": "avenwu <avwu@qq.com>",
11
11
  "contributors": [],
@@ -39,7 +39,7 @@
39
39
  "dependencies": {
40
40
  "adm-zip": "^0.6.1",
41
41
  "async-limiter": "2.0.0",
42
- "body-parser": "^1.20.6",
42
+ "body-parser": "^1.20.9",
43
43
  "colors": "1.1.2",
44
44
  "express": "^4.21.2",
45
45
  "extend": "^3.0.2",
@@ -51,7 +51,7 @@
51
51
  "lru-cache": "^4.1.1",
52
52
  "mime": "^1.6.0",
53
53
  "multer2": "^1.1.1",
54
- "node-forge": "^1.4.1",
54
+ "node-forge": "^1.4.2",
55
55
  "node-pac": "^0.5.1",
56
56
  "parseurl": "^1.3.1",
57
57
  "pfork": "^0.6.3",