Add redirect option to strip headers on redirect by mcollina · Pull Request #5281 · nodejs/undici (original) (raw)
Conversation
This relates to...
N/A
Rationale
Allow callers using the redirect interceptor to remove selected custom request headers before a redirected request is dispatched, with support for both all redirects and cross-origin redirects only.
Changes
Features
- Add
stripHeadersOnRedirectto the redirect interceptor options. - Add
stripHeadersOnCrossOriginRedirectto strip selected headers only when redirecting across origins. - Apply configured header stripping during redirect request header cleanup.
- Add type definitions, docs, and tests for the new options.
Bug Fixes
- Import the
node:testafterhook intest/parser-issues.jsso the current main test additions pass lint and CI.
Breaking Changes and Deprecations
N/A
Status
- I have read and agreed to the Developer's Certificate of Origin
- Tested
- Benchmarked (optional)
- Documented
- Review ready
- In review
- Merge ready
Tests
npx borp --timeout 180000 -p "test/interceptors/redirect.js"npx borp --timeout 180000 -p "test/parser-issues.js"npx tsd --files test/types/redirect-interceptor.test-d.tsnpx eslint lib/interceptor/redirect.js lib/handler/redirect-handler.js test/interceptors/redirect.jsnpx eslint test/parser-issues.js lib/interceptor/redirect.js lib/handler/redirect-handler.js test/interceptors/redirect.js
Codecov Report
❌ Patch coverage is 89.74359% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.25%. Comparing base (13f6af6) to head (48d84f7).
⚠️ Report is 3 commits behind head on main.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| lib/handler/redirect-handler.js | 88.88% | 4 Missing ⚠️ |
Additional details and impacted files
@@ Coverage Diff @@ ## main #5281 +/- ##
Coverage 93.26% 93.25% -0.01%
Files 110 110
Lines 36533 36558 +25
- Hits 34071 34092 +21
- Misses 2462 2466 +4
☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.
🚀 New features to boost your workflow:
- ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
mcollina deleted the add-redirect-strip-headers-option branch
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
[ Show hidden characters]({{ revealButtonHref }})