@requestly/requestly-proxy 1.3.5 → 1.3.6

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.
@@ -236,7 +236,7 @@ class ProxyMiddlewareManager {
236
236
  this.init_handlers = () => {
237
237
  this.proxy.onRequestHandlers = [];
238
238
  this.proxy.onConnectHandlers = [];
239
- this.proxy.use(proxy_1.default.gunzip);
239
+ this.proxy.use(proxy_1.default.decompress);
240
240
  // this.init_ssl_tunneling_handler();
241
241
  this.init_amiusing_handler();
242
242
  this.init_ssl_cert_handler();
@@ -1,2 +1,2 @@
1
1
  export default DefaultExport;
2
- export { Proxy, PROXY_HANDLER_TYPE, gunzip, wildcard };
2
+ export { Proxy, PROXY_HANDLER_TYPE, gunzip, decompress, wildcard };
@@ -23,10 +23,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.wildcard = exports.gunzip = exports.PROXY_HANDLER_TYPE = exports.Proxy = void 0;
26
+ exports.wildcard = exports.decompress = exports.gunzip = exports.PROXY_HANDLER_TYPE = exports.Proxy = void 0;
27
27
  const proxy_1 = __importStar(require("./lib/proxy"));
28
28
  Object.defineProperty(exports, "Proxy", { enumerable: true, get: function () { return proxy_1.Proxy; } });
29
29
  Object.defineProperty(exports, "PROXY_HANDLER_TYPE", { enumerable: true, get: function () { return proxy_1.PROXY_HANDLER_TYPE; } });
30
30
  Object.defineProperty(exports, "gunzip", { enumerable: true, get: function () { return proxy_1.gunzip; } });
31
+ Object.defineProperty(exports, "decompress", { enumerable: true, get: function () { return proxy_1.decompress; } });
31
32
  Object.defineProperty(exports, "wildcard", { enumerable: true, get: function () { return proxy_1.wildcard; } });
32
33
  exports.default = proxy_1.default;
@@ -0,0 +1,2 @@
1
+ export function onResponse(ctx: any, callback: any): any;
2
+ export function onRequest(ctx: any, callback: any): any;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var zlib = require("zlib");
3
+ const decompressMiddleware = {
4
+ onResponse: function (ctx, callback) {
5
+ if (ctx.serverToProxyResponse.headers["content-encoding"] &&
6
+ ctx.serverToProxyResponse.headers["content-encoding"].toLowerCase() ==
7
+ "gzip") {
8
+ delete ctx.serverToProxyResponse.headers["content-encoding"];
9
+ ctx.addResponseFilter(zlib.createGunzip());
10
+ }
11
+ else if (ctx.serverToProxyResponse.headers["content-encoding"] &&
12
+ ctx.serverToProxyResponse.headers["content-encoding"].toLowerCase() ==
13
+ "br") {
14
+ delete ctx.serverToProxyResponse.headers["content-encoding"];
15
+ ctx.addResponseFilter(zlib.createBrotliDecompress());
16
+ }
17
+ return callback();
18
+ },
19
+ onRequest: function (ctx, callback) {
20
+ ctx.proxyToServerRequestOptions.headers["accept-encoding"] = "gzip";
21
+ return callback();
22
+ },
23
+ };
24
+ module.exports = decompressMiddleware;
@@ -21,6 +21,7 @@ module.exports = function () {
21
21
  return new Proxy();
22
22
  };
23
23
  module.exports.gunzip = require("./middleware/gunzip");
24
+ module.exports.decompress = require("./middleware/decompress");
24
25
  module.exports.wildcard = require("./middleware/wildcard");
25
26
  var Proxy = function () {
26
27
  this.onConnectHandlers = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@requestly/requestly-proxy",
3
- "version": "1.3.5",
3
+ "version": "1.3.6",
4
4
  "description": "Proxy that gives superpowers to all the Requestly clients",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",