This recipe migrates code from using deprecated private header fields (_headers, _headerNames) on OutgoingMessage.prototype to their public API equivalents.
Deprecation
Node.js deprecated direct access to private header fields. Use the public methods getHeaders() and getRawHeaderNames() instead.
See DEP0066 for more details.
Usage
Run this codemod with:
Before/After
What It Does
- Replaces
res._headers with res.getHeaders()
- Replaces
res._headerNames with res.getRawHeaderNames()
- Updates property access and method calls throughout your codebase
- Works with
ServerResponse and other OutgoingMessage subclasses
Migration Guide
Direct access to private fields (prefixed with _) is not part of the public API and can break without notice. Always use public methods.
References