villadora / express-http-proxy

Proxy middleware for express/connect
Other
1.22k stars 236 forks source link

[#545] Fixes => `content-length` request header is removed when parse… #549

Closed monkpow closed 3 weeks ago

monkpow commented 3 weeks ago

…ReqBody is false.

monkpow commented 3 weeks ago

This fixes the issue raised in #545 and adds tests to confirm the behavior.

However, when testing this solution I found the following test does not pass:

-      it.only('when the author uses a proxyReqDecorator', function (done) {
-        var app = express();
-        app.use(proxy('localhost:8109', {
-          proxyReqBodyDecorator: function() {
-            return 'hey man';
-          }
-        }));
-
-        request(app)
-          .post('/headers')
-          .send({
-            data: 'random string of words'
-          })
-          .set('Content-Type', 'application/json')
-          .set('Accept', 'application/json')
-          .end(function (err, res) {
-            if (err) { throw err; }
-            assert(res.body.headers['content-length']);
-            const contentLength = res.body.headers['content-length'];
-            assert.equal(contentLength, 18);
-            done(err);
-          });
-      });
-

I suspect this was already true, but I'm raising an additional issue to investigate the test above.

monkpow commented 3 weeks ago

I created an issue (#550) to capture the case I discovered. That test is in the same state on the main line, so I'm going to separate these two tickets, and move this one to resolution.