Skip to content

Commit bc17e81

Browse files
authored
Make get-stream a devDependency (#2365)
1 parent 5e2f0b3 commit bc17e81

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
"cacheable-request": "^12.0.1",
5555
"decompress-response": "^6.0.0",
5656
"form-data-encoder": "^4.0.2",
57-
"get-stream": "^8.0.1",
5857
"http2-wrapper": "^2.2.1",
5958
"lowercase-keys": "^3.0.0",
6059
"p-cancelable": "^4.0.1",
@@ -86,6 +85,7 @@
8685
"express": "^4.19.2",
8786
"form-data": "^4.0.0",
8887
"formdata-node": "^6.0.3",
88+
"get-stream": "^9.0.1",
8989
"nock": "^13.5.4",
9090
"node-fetch": "^3.3.2",
9191
"np": "^10.0.5",

Diff for: readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ By default, Got will retry on failure. To disable this option, set [`options.ret
374374

375375
[Click here][InstallSizeOfTheDependencies] to see the install size of the Got dependencies.
376376

377-
377+
378378

379379
## Maintainers
380380

Diff for: source/core/index.ts

+3-7
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ import CacheableRequest, {
1111
type CacheableOptions,
1212
} from 'cacheable-request';
1313
import decompressResponse from 'decompress-response';
14-
import is from '@sindresorhus/is';
15-
import {getStreamAsBuffer} from 'get-stream';
14+
import is, {isBuffer} from '@sindresorhus/is';
1615
import {FormDataEncoder, isFormData as isFormDataLike} from 'form-data-encoder';
1716
import type ResponseLike from 'responselike';
1817
import getBodySize from './utils/get-body-size.js';
@@ -877,11 +876,8 @@ export default class Request extends Duplex implements RequestEvents<Request> {
877876

878877
try {
879878
// Errors are emitted via the `error` event
880-
const rawBody = await getStreamAsBuffer(from);
881-
882-
// TODO: Switch to this:
883-
// let rawBody = await from.toArray();
884-
// rawBody = Buffer.concat(rawBody);
879+
const fromArray = await from.toArray();
880+
const rawBody = isBuffer(fromArray.at(0)) ? Buffer.concat(fromArray) : Buffer.from(fromArray.join(''));
885881

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

0 commit comments

Comments
 (0)