Skip to content

Commit

Permalink
Make get-stream a devDependency (#2365)
Browse files Browse the repository at this point in the history
  • Loading branch information
bjornstar authored Jul 11, 2024
1 parent 5e2f0b3 commit bc17e81
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 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
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ By default, Got will retry on failure. To disable this option, set [`options.ret

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

[InstallSizeOfTheDependencies]: https://packagephobia.com/result?p=@sindresorhus/is@6.3.1,@szmarczak/[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected]
[InstallSizeOfTheDependencies]: https://packagephobia.com/result?p=@sindresorhus/is@7.0.0,@szmarczak/[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected]

## Maintainers

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 = isBuffer(fromArray.at(0)) ? 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 bc17e81

Please sign in to comment.