Skip to content

Commit

Permalink
Revert "fix(core): Handle gzip and deflate compressed request payloads (
Browse files Browse the repository at this point in the history
  • Loading branch information
mutdmour committed Nov 30, 2023
1 parent 627ddb9 commit 21bec4a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 57 deletions.
19 changes: 2 additions & 17 deletions packages/cli/src/middlewares/bodyParser.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import getRawBody from 'raw-body';
import { type Readable } from 'stream';
import { createGunzip, createInflate } from 'zlib';
import type { Request, RequestHandler } from 'express';
import { parse as parseQueryString } from 'querystring';
import { Parser as XmlParser } from 'xml2js';
Expand All @@ -22,21 +20,8 @@ export const rawBodyReader: RequestHandler = async (req, res, next) => {

req.readRawBody = async () => {
if (!req.rawBody) {
let stream: Readable = req;
let contentLength: string | undefined;
const contentEncoding = req.headers['content-encoding'];
switch (contentEncoding) {
case 'gzip':
stream = req.pipe(createGunzip());
break;
case 'deflate':
stream = req.pipe(createInflate());
break;
default:
contentLength = req.headers['content-length'];
}
req.rawBody = await getRawBody(stream, {
length: contentLength,
req.rawBody = await getRawBody(req, {
length: req.headers['content-length'],
limit: `${String(payloadSizeMax)}mb`,
});
req._body = true;
Expand Down
40 changes: 0 additions & 40 deletions packages/cli/test/integration/middlewares/bodyParser.test.ts

This file was deleted.

0 comments on commit 21bec4a

Please sign in to comment.