Repository navigation
docs: document recent Express 5 and body-parser behavior in the API reference - #2576
Open
NopeCharon wants to merge 1 commit into
Open
NopeCharon wants to merge 1 commit into
NopeCharon wants to merge 1 commit into
Conversation
…eference
The 5.x API reference had not caught up with behavior shipped in Express
5.1.0 through 5.3.0 and in body-parser 2.x. Each item below was checked
against express@5.3.0 and body-parser@2.4.0.
express.json(), express.raw(), express.text(), express.urlencoded():
- List every supported Content-Encoding: br has been supported since
body-parser 2.0.0, and zstd since 2.4.0 (Node.js ^22.15.0 or >=23.8.0;
older runtimes reject zstd bodies with 415). The pages only listed
gzip and deflate.
- Document that an invalid `limit` (NaN, or a string that bytes cannot
parse) now throws a TypeError when the middleware is created, while
null and undefined use the 100kb default (body-parser 2.3.0).
res.send():
- Accept Uint8Array bodies, which are sent as application/octet-stream
like Buffers (5.1.0).
- Content-Length is not set when Transfer-Encoding is already present
(5.3.0).
- With a preset Content-Type, string bodies keep the existing parameters
and get charset=utf-8 (5.3.0).
res.sendFile():
- The ETag header follows the application's `etag` setting and is only
turned off by app.set('etag', false); it is always a weak ETag based
on file size and mtime (5.1.0).
res.redirect():
- Document the deprecation warnings emitted for a missing or non-string
URL and a non-numeric status (5.2.0).
req.fresh (4.x and 5.x):
- Freshness is only checked for GET, HEAD and QUERY requests with a 2xx
or 304 status. QUERY was added in 5.3.0 and 4.22.3; the 4.x page says
which version, matching how that page notes other version-specific
behavior.
Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com>
✅ Deploy Preview for expressjscom-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

The 5.x API reference never picked up some behavior that shipped in Express 5.1.0–5.3.0 and body-parser 2.x. This PR documents it. I checked each change against the source and against a running
express@5.3.0/body-parser@2.4.0app.express.json(),.raw(),.text(),.urlencoded()brandzstdalongsidegzipanddeflate.zstdneeds Node.js^22.15.0or>=23.8.0; older runtimes respond415br), 2.4.0 (zstd)limit(NaN, or a stringbytescan't parse) now throws aTypeErrorwhen the middleware is created;null/undefineduse the defaultres.send()Uint8Arraybodies are accepted and sent asapplication/octet-streamres.send()Content-Lengthis skipped whenTransfer-Encodingis already setres.send()Content-Type, string bodies keep its parameters and getcharset=utf-8res.sendFile()ETagheader follows the app'setagsetting (onlyfalseturns it off), and it is always a weak ETagres.redirect()req.fresh(4.x and 5.x)GET,HEADandQUERYrequests with a2xx/304status. The 4.x page also notes thatQUERYwas added in 4.22.3The new
Content-Dispositionoutput fromres.attachment()(content-disposition 2.x) is left out because #2551 already updates that example.Validation
limitvalue,Uint8Arraybodies, presetTransfer-EncodingandContent-Type,sendFilewithetagset tofalseand to"strong",res.redirect(undefined), andreq.freshforGET/HEAD/QUERY/POST. The observed headers and warnings match the text and examples.npm run check(Prettier, ESLint, cspell) andnpm run test:unitpass.npm run buildpasses. In the generated HTML the new#options-for-etag-settinglink resolves on the 5.x application page.