node-fetch+2.7.0.patch 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. diff --git a/node_modules/node-fetch/lib/index.js b/node_modules/node-fetch/lib/index.js
  2. index 567ff5d..8eb45f7 100644
  3. --- a/node_modules/node-fetch/lib/index.js
  4. +++ b/node_modules/node-fetch/lib/index.js
  5. @@ -545,8 +545,8 @@ function clone(instance) {
  6. // tee instance body
  7. p1 = new PassThrough();
  8. p2 = new PassThrough();
  9. - body.pipe(p1);
  10. - body.pipe(p2);
  11. + Stream.pipeline(body, p1, () => {});
  12. + Stream.pipeline(body, p2, () => {});
  13. // set instance body to teed body and return the other teed body
  14. instance[INTERNALS].body = p1;
  15. body = p2;
  16. @@ -648,14 +648,14 @@ function writeToStream(dest, instance) {
  17. // body is null
  18. dest.end();
  19. } else if (isBlob(body)) {
  20. - body.stream().pipe(dest);
  21. + Stream.pipeline(body.stream(), dest, () => {});
  22. } else if (Buffer.isBuffer(body)) {
  23. // body is buffer
  24. dest.write(body);
  25. dest.end();
  26. } else {
  27. // body is stream
  28. - body.pipe(dest);
  29. + Stream.pipeline(body, dest, () => {});
  30. }
  31. }
  32. @@ -1638,7 +1638,7 @@ function fetch(url, opts) {
  33. res.once('end', function () {
  34. if (signal) signal.removeEventListener('abort', abortAndFinalize);
  35. });
  36. - let body = res.pipe(new PassThrough$1());
  37. + let body = Stream.pipeline(res, new PassThrough(), error => { if (error) reject(error); });
  38. const response_options = {
  39. url: request.url,
  40. @@ -1679,7 +1679,7 @@ function fetch(url, opts) {
  41. // for gzip
  42. if (codings == 'gzip' || codings == 'x-gzip') {
  43. - body = body.pipe(zlib.createGunzip(zlibOptions));
  44. + body = Stream.pipeline(body, zlib.createGunzip(zlibOptions), error => { if (error) reject(error); });
  45. response = new Response(body, response_options);
  46. resolve(response);
  47. return;
  48. @@ -1689,13 +1689,13 @@ function fetch(url, opts) {
  49. if (codings == 'deflate' || codings == 'x-deflate') {
  50. // handle the infamous raw deflate response from old servers
  51. // a hack for old IIS and Apache servers
  52. - const raw = res.pipe(new PassThrough$1());
  53. + const raw = Stream.pipeline(res, new PassThrough(), error => { if (error) reject(error); });
  54. raw.once('data', function (chunk) {
  55. // see http://stackoverflow.com/questions/37519828
  56. if ((chunk[0] & 0x0F) === 0x08) {
  57. - body = body.pipe(zlib.createInflate());
  58. + body = Stream.pipeline(body, zlib.createInflate(), error => { if (error) reject(error); });
  59. } else {
  60. - body = body.pipe(zlib.createInflateRaw());
  61. + body = Stream.pipeline(body, zlib.createInflateRaw(), error => { if (error) reject(error); });
  62. }
  63. response = new Response(body, response_options);
  64. resolve(response);
  65. @@ -1712,7 +1712,7 @@ function fetch(url, opts) {
  66. // for br
  67. if (codings == 'br' && typeof zlib.createBrotliDecompress === 'function') {
  68. - body = body.pipe(zlib.createBrotliDecompress());
  69. + body = Stream.pipeline(body, zlib.createBrotliDecompress(), error => { if (error) reject(error); });
  70. response = new Response(body, response_options);
  71. resolve(response);
  72. return;