Skip to content

Commit

Permalink
Make get-stream a devDependency
Browse files Browse the repository at this point in the history
  • Loading branch information
bjornstar committed Jul 11, 2024
1 parent 561a376 commit a5b1106
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
"cacheable-request": "^12.0.1",
"decompress-response": "^6.0.0",
"form-data-encoder": "^4.0.2",
"get-stream": "^8.0.1",
"http2-wrapper": "^2.2.1",
"lowercase-keys": "^3.0.0",
"p-cancelable": "^4.0.1",
Expand Down Expand Up @@ -86,6 +85,7 @@
"express": "^4.19.2",
"form-data": "^4.0.0",
"formdata-node": "^6.0.3",
"get-stream": "^9.0.1",
"nock": "^13.5.4",
"node-fetch": "^3.3.2",
"np": "^10.0.5",
Expand Down
10 changes: 3 additions & 7 deletions source/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import CacheableRequest, {
type CacheableOptions,
} from 'cacheable-request';
import decompressResponse from 'decompress-response';
import is from '@sindresorhus/is';
import {getStreamAsBuffer} from 'get-stream';
import is, {isBuffer} from '@sindresorhus/is';
import {FormDataEncoder, isFormData as isFormDataLike} from 'form-data-encoder';
import type ResponseLike from 'responselike';
import getBodySize from './utils/get-body-size.js';
Expand Down Expand Up @@ -877,11 +876,8 @@ export default class Request extends Duplex implements RequestEvents<Request> {

try {
// Errors are emitted via the `error` event
const rawBody = await getStreamAsBuffer(from);

// TODO: Switch to this:
// let rawBody = await from.toArray();
// rawBody = Buffer.concat(rawBody);
const fromArray = await from.toArray();
const rawBody = fromArray.every(b => isBuffer(b)) ? Buffer.concat(fromArray) : Buffer.from(fromArray.join(''));

// On retry Request is destroyed with no error, therefore the above will successfully resolve.
// So in order to check if this was really successfull, we need to check if it has been properly ended.
Expand Down

0 comments on commit a5b1106

Please sign in to comment.