http-proxy-middleware 2.0.7 → 2.0.9

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/README.md CHANGED
@@ -595,4 +595,4 @@ $ yarn spellcheck
595
595
 
596
596
  The MIT License (MIT)
597
597
 
598
- Copyright (c) 2015-2022 Steven Chim
598
+ Copyright (c) 2015-2025 Steven Chim
@@ -6,20 +6,27 @@ const querystring = require("querystring");
6
6
  * Fix proxied body if bodyParser is involved.
7
7
  */
8
8
  function fixRequestBody(proxyReq, req) {
9
+ // skip fixRequestBody() when req.readableLength not 0 (bodyParser failure)
10
+ if (req.readableLength !== 0) {
11
+ return;
12
+ }
9
13
  const requestBody = req.body;
10
14
  if (!requestBody) {
11
15
  return;
12
16
  }
13
17
  const contentType = proxyReq.getHeader('Content-Type');
18
+ if (!contentType) {
19
+ return;
20
+ }
14
21
  const writeBody = (bodyData) => {
15
22
  // deepcode ignore ContentLengthInCode: bodyParser fix
16
23
  proxyReq.setHeader('Content-Length', Buffer.byteLength(bodyData));
17
24
  proxyReq.write(bodyData);
18
25
  };
19
- if (contentType && contentType.includes('application/json')) {
26
+ if (contentType.includes('application/json')) {
20
27
  writeBody(JSON.stringify(requestBody));
21
28
  }
22
- if (contentType && contentType.includes('application/x-www-form-urlencoded')) {
29
+ else if (contentType.includes('application/x-www-form-urlencoded')) {
23
30
  writeBody(querystring.stringify(requestBody));
24
31
  }
25
32
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "http-proxy-middleware",
3
- "version": "2.0.7",
3
+ "version": "2.0.9",
4
4
  "description": "The one-liner node.js proxy middleware for connect, express and browser-sync",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",