@midwayjs/http-proxy 3.5.2 → 3.6.0

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.
@@ -10,9 +10,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.HttpProxyConfiguration = void 0;
13
- const decorator_1 = require("@midwayjs/decorator");
14
- const DefaultConfig = require("./config/config.default");
15
13
  const core_1 = require("@midwayjs/core");
14
+ const DefaultConfig = require("./config/config.default");
16
15
  const middleware_1 = require("./middleware");
17
16
  let HttpProxyConfiguration = class HttpProxyConfiguration {
18
17
  async onReady() {
@@ -26,15 +25,15 @@ let HttpProxyConfiguration = class HttpProxyConfiguration {
26
25
  }
27
26
  };
28
27
  __decorate([
29
- (0, decorator_1.Inject)(),
28
+ (0, core_1.Inject)(),
30
29
  __metadata("design:type", core_1.MidwayApplicationManager)
31
30
  ], HttpProxyConfiguration.prototype, "applicationManager", void 0);
32
31
  __decorate([
33
- (0, decorator_1.Config)('httpProxy'),
32
+ (0, core_1.Config)('httpProxy'),
34
33
  __metadata("design:type", Object)
35
34
  ], HttpProxyConfiguration.prototype, "httpProxy", void 0);
36
35
  HttpProxyConfiguration = __decorate([
37
- (0, decorator_1.Configuration)({
36
+ (0, core_1.Configuration)({
38
37
  namespace: 'upload',
39
38
  importConfigs: [
40
39
  {
@@ -2,6 +2,7 @@ export interface HttpProxyStrategy {
2
2
  match?: RegExp;
3
3
  host?: string;
4
4
  target?: string;
5
+ proxyTimeout?: number;
5
6
  ignoreHeaders?: {
6
7
  [key: string]: boolean;
7
8
  };
@@ -10,11 +10,11 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.HttpProxyMiddleware = void 0;
13
- const decorator_1 = require("@midwayjs/decorator");
13
+ const core_1 = require("@midwayjs/core");
14
14
  const axios_1 = require("axios");
15
15
  let HttpProxyMiddleware = class HttpProxyMiddleware {
16
16
  resolve(app) {
17
- if (app.getFrameworkType() === decorator_1.MidwayFrameworkType.WEB_EXPRESS) {
17
+ if (app.getFrameworkType() === core_1.MidwayFrameworkType.WEB_EXPRESS) {
18
18
  return async (req, res, next) => {
19
19
  return this.execProxy(req, req, res, next, true);
20
20
  };
@@ -47,6 +47,7 @@ let HttpProxyMiddleware = class HttpProxyMiddleware {
47
47
  ? `${forwarded}, ${ctx.ip}`
48
48
  : ctx.ip;
49
49
  reqHeaders['host'] = url.host;
50
+ delete reqHeaders['content-length'];
50
51
  const method = req.method.toUpperCase();
51
52
  const targetRes = res.res || res;
52
53
  const isStream = targetRes.on && targetRes.writable;
@@ -55,6 +56,7 @@ let HttpProxyMiddleware = class HttpProxyMiddleware {
55
56
  url: url.href,
56
57
  headers: reqHeaders,
57
58
  responseType: isStream ? 'stream' : 'arrayBuffer',
59
+ timeout: this.httpProxy.proxyTimeout || 0,
58
60
  };
59
61
  if (method === 'POST' || method === 'PUT') {
60
62
  reqOptions.data = (_b = req.body) !== null && _b !== void 0 ? _b : (_c = ctx.request) === null || _c === void 0 ? void 0 : _c.body;
@@ -137,15 +139,15 @@ let HttpProxyMiddleware = class HttpProxyMiddleware {
137
139
  }
138
140
  };
139
141
  __decorate([
140
- (0, decorator_1.Config)('httpProxy'),
142
+ (0, core_1.Config)('httpProxy'),
141
143
  __metadata("design:type", Object)
142
144
  ], HttpProxyMiddleware.prototype, "httpProxy", void 0);
143
145
  __decorate([
144
- (0, decorator_1.Logger)(),
146
+ (0, core_1.Logger)(),
145
147
  __metadata("design:type", Object)
146
148
  ], HttpProxyMiddleware.prototype, "logger", void 0);
147
149
  HttpProxyMiddleware = __decorate([
148
- (0, decorator_1.Middleware)()
150
+ (0, core_1.Middleware)()
149
151
  ], HttpProxyMiddleware);
150
152
  exports.HttpProxyMiddleware = HttpProxyMiddleware;
151
153
  //# sourceMappingURL=middleware.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/http-proxy",
3
- "version": "3.5.2",
3
+ "version": "3.6.0",
4
4
  "description": "Midway Component for http proxy",
5
5
  "main": "dist/index.js",
6
6
  "typings": "index.d.ts",
@@ -29,14 +29,13 @@
29
29
  "axios": "0.27.2"
30
30
  },
31
31
  "devDependencies": {
32
- "@midwayjs/core": "^3.5.1",
33
- "@midwayjs/decorator": "^3.4.11",
34
- "@midwayjs/express": "^3.5.1",
35
- "@midwayjs/faas": "^3.5.2",
36
- "@midwayjs/koa": "^3.5.1",
37
- "@midwayjs/mock": "^3.5.1",
38
- "@midwayjs/serverless-app": "^3.5.2",
39
- "@midwayjs/web": "^3.5.1"
32
+ "@midwayjs/core": "^3.6.0",
33
+ "@midwayjs/express": "^3.6.0",
34
+ "@midwayjs/faas": "^3.6.0",
35
+ "@midwayjs/koa": "^3.6.0",
36
+ "@midwayjs/mock": "^3.6.0",
37
+ "@midwayjs/serverless-app": "^3.6.0",
38
+ "@midwayjs/web": "^3.6.0"
40
39
  },
41
- "gitHead": "bfdca205f0c9321066ec480cd244eee043dccab0"
40
+ "gitHead": "22643b0e8519766bb7c68b975930199fc136336e"
42
41
  }