From b0436bd144c6a34f1adc9b25cc94fe5bff5c369c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B5=D1=82=D1=80=20=D0=97=D0=B0=D0=B4=D0=B5=D1=80?= =?UTF-8?q?=D0=B5=D0=B9?= Date: Wed, 7 Oct 2026 15:32:55 +0300 Subject: [PATCH 1/2] doc: mention built-in stream consumers for http body parsing --- pages/http/anatomy-of-an-http-transaction.md | 25 +++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/pages/http/anatomy-of-an-http-transaction.md b/pages/http/anatomy-of-an-http-transaction.md index 54cd303..b4477c8 100644 --- a/pages/http/anatomy-of-an-http-transaction.md +++ b/pages/http/anatomy-of-an-http-transaction.md @@ -108,9 +108,28 @@ request ``` > This may seem a tad tedious, and in many cases, it is. Luckily, -> there are modules like [`concat-stream`][] and [`body`][] on [`npm`][] which can -> help hide away some of this logic. It's important to have a good understanding -> of what's going on before going down that road, and that's why you're here! +> there is a built-in module [`node:stream/consumers`](https://nodejs.org/api/webstreams.html#utility-consumers), or npm packages like +> [`concat-stream`][] and [`body`][] which can help hide away some of this +> logic. It's important to have a good understanding of what's going on before +> going down that road, and that's why you're here! + +```cjs +const { text } = require('node:stream/consumers'); +const http = require('node:http'); + +const server = http.createServer(async (request, response) => { + let body = await text(request); +}); +``` + +```mjs +import { text } from 'node:stream/consumers'; +import http from 'node:http'; + +const server = http.createServer(async (request, response) => { + let body = await text(request); +}); +``` ## A Quick Thing About Errors From 16a5989b9dc9bed1df377cfcd123349ec3460814 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B5=D1=82=D1=80=20=D0=97=D0=B0=D0=B4=D0=B5=D1=80?= =?UTF-8?q?=D0=B5=D0=B9?= Date: Wed, 7 Oct 2026 15:39:04 +0300 Subject: [PATCH 2/2] doc: fix consumers doc hyperlink markdown --- pages/http/anatomy-of-an-http-transaction.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pages/http/anatomy-of-an-http-transaction.md b/pages/http/anatomy-of-an-http-transaction.md index b4477c8..e4b5797 100644 --- a/pages/http/anatomy-of-an-http-transaction.md +++ b/pages/http/anatomy-of-an-http-transaction.md @@ -108,7 +108,7 @@ request ``` > This may seem a tad tedious, and in many cases, it is. Luckily, -> there is a built-in module [`node:stream/consumers`](https://nodejs.org/api/webstreams.html#utility-consumers), or npm packages like +> there is a built-in module [`node:stream/consumers`][], or npm packages like > [`concat-stream`][] and [`body`][] which can help hide away some of this > logic. It's important to have a good understanding of what's going on before > going down that road, and that's why you're here! @@ -600,6 +600,7 @@ read through the API docs for [`EventEmitters`][], [`Streams`][], and [`HTTP`][] [`ReadableStream`]: https://nodejs.org/api/stream.html#stream_class_stream_readable [`rawHeaders`]: https://nodejs.org/api/http.html#http_message_rawheaders [`Buffer`]: https://nodejs.org/api/buffer.html +[`node:stream/consumers`]: https://nodejs.org/api/webstreams.html#utility-consumers [`concat-stream`]: https://www.npmjs.com/package/concat-stream [`body`]: https://www.npmjs.com/package/body [`npm`]: https://www.npmjs.com