Skip to content

Conversation

@Guest0x0
Copy link
Collaborator

This PR adds CONNECT based proxy support to @http.Client and the various request methods. A new optional argument proxy? : @http.Client is added to @http.Client::new and the various request helpers. When present, proxy should be a @http.Client in a clean state (i.e. not in the middle of a request). The new client will send a CONNECT request to the proxy client. If the proxy client response with a 2XX response code, the proxy client will be set to pass-through mode, and all subsequent traffic in the new client will go through the proxy client tunnel.

The merits of using another @http.Client as proxy (compared to #191):

  • https support (the CONNECT request itself is encrypted) come for free
  • proxy authentication is easy to perform: just set extra headers for the proxy client

Some examples can be found in src/http/proxy_test.mbt.

cc @Milky2018

@coveralls
Copy link

coveralls commented Nov 24, 2025

Pull Request Test Coverage Report for Build 828

Details

  • 46 of 52 (88.46%) changed or added relevant lines in 6 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.7%) to 79.379%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/http/parser.mbt 5 6 83.33%
src/http/client.mbt 25 30 83.33%
Totals Coverage Status
Change from base Build 826: 0.7%
Covered Lines: 1432
Relevant Lines: 1804

💛 - Coveralls

@Guest0x0 Guest0x0 merged commit 77ffb44 into main Nov 24, 2025
11 checks passed
@Guest0x0 Guest0x0 deleted the http-proxy branch November 24, 2025 07:10
@Milky2018
Copy link

Excellent work! Thanks for CC-ing me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants