Feat/support connect method#1
Merged
Merged
Conversation
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.
Summary
This PR completes HTTP CONNECT method support for proxy scenarios, enabling the interceptors library to properly handle HTTP tunneling
requests used by proxy agents like
hpagent.Key Improvements
pathoption contains the target host rather than a URL pathChanges Made
Core Fixes
normalizeClientRequestArgs.ts- Handle empty URL strings for CONNECT requestsgetUrlByRequestOptions.ts- Proper path handling for CONNECT method (target host vs URL path)got-hpagent-proxy.test.ts- Complete proxy flow test with tunneled requestsEnhanced Debugging
NodeClientRequest.ts- Added detailed logging for CONNECT request lifecyclecreateRequest.ts- Added logging for request construction detailsTest Results
Both CONNECT-related tests now pass:
test/modules/http/compliance/http-connect.test.ts- Basic CONNECT functionalitytest/third-party/got-hpagent-proxy.test.ts- Real-world proxy agent integrationProxy Flow Support
The library now properly supports the complete proxy flow:
Real-World Impact
This enables libraries like
vcr-jsto properly intercept and mock proxy-based HTTP requests, which is crucial for testingapplications that use corporate proxies or HTTP tunneling.
Debugging
Added comprehensive logging that can be enabled with:
DEBUG=interceptors* your-command Shows detailed information about: - CONNECT request creation and URL construction - Proxy authentication headers - Response handling and tunnel establishment - Error scenarios with detailed context Test plan - Run existing unit tests - all pass - Run CONNECT-specific integration tests - both pass - Test with real proxy scenario (got + hpagent) - works correctly - Verify backward compatibility - no regressions - Test logging output - comprehensive debugging available 🤖 Generated with https://claude.ai/code