This recipe migrates code from using deprecated private header fields (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/nodejs/userland-migrations/llms.txt
Use this file to discover all available pages before exploring further.
_headers, _headerNames) on OutgoingMessage.prototype to their public API equivalents.
Deprecation
Node.js deprecated direct access to private header fields. Use the public methodsgetHeaders() and getRawHeaderNames() instead.
See DEP0066 for more details.
Usage
Run this codemod with:Before/After
What It Does
- Replaces
res._headerswithres.getHeaders() - Replaces
res._headerNameswithres.getRawHeaderNames() - Updates property access and method calls throughout your codebase
- Works with
ServerResponseand otherOutgoingMessagesubclasses
Migration Guide
| Deprecated | Replacement |
|---|---|
res._headers | res.getHeaders() |
res._headerNames | res.getRawHeaderNames() |