Skip to content

Fix Net::HTTP, HTTP.rb, RestClient, and Faraday CONNECT headers - #48

Merged
proxymesh merged 3 commits into
mainfrom
cursor/fix-connect-adapters-8740
Nov 13, 2026
Merged

proxymesh merged 3 commits into
mainfrom
cursor/fix-connect-adapters-8740

Conversation

@proxymeshai

Copy link
Copy Markdown
Collaborator

Net::HTTP#connect was a copy of the Ruby 3.2 method, so it drifted from the installed net-http (timeouted_connect, HTTPS proxies). HTTP.rb and RestClient also called the missing RubyProxyHeaders::NetHTTP.request.

  • The patch now prepends a thin wrapper. Upstream still opens the socket and writes CONNECT. Custom headers are inserted into that request, and the CONNECT response is kept. Lookup of X-ProxyMesh-IP is case-insensitive. patch! still applies after WebMock swaps Net::HTTP out and restores it.
  • HTTP.rb 6 sends proxy_headers on CONNECT itself. proxy_response_headers reads response.proxy_headers.
  • RestClient still performs the request. The patch sets CONNECT headers on the Net::HTTP object RestClient builds.
  • Faraday no longer overrides private request_with_wrapped_block. It uses public build_connection and call.

CONNECT headers are not copied onto the origin request. Version stays 0.2.3.

Local mock proxy on Ruby 3.2.3 with the locked gems (net-http 0.10.0, faraday-net_http 3.5.0, http 6.0.4, rest-client 2.1.0): Net::HTTP, HTTP.rb, RestClient, Faraday, and HTTParty each sent X-ProxyMesh-Country only on CONNECT, kept X-App-Secret on the origin request, and read X-ProxyMesh-IP. An HTTPS proxy (proxy_use_ssl) started with a TLS handshake and still carried the custom CONNECT header. bundle exec rspec was 41 examples, 0 failures, 6 pending.

Merge after #47. The docs PR is stacked on this branch.

Open in Web Open in Cursor 

@proxymeshai
proxymeshai added this pull request to stack #49 November 12, 2026 21:59
@cursor
cursor Bot force-pushed the cursor/fix-connect-adapters-8740 branch from c429353 to 45fc194 Compare November 12, 2026 22:19
Base automatically changed from cursor/typhoeus-native-proxyheader-8740 to main November 13, 2026 02:50
cursoragent and others added 3 commits November 12, 2026 18:50
Stop copying Net::HTTP#connect. HTTP.rb uses its own proxy headers,
RestClient keeps using Net::HTTP, and Faraday reads the CONNECT response
through public adapter methods.

Co-authored-by: ProxyMesh AI <proxymeshai@users.noreply.github.com>
The live harness only reads Hash headers, and HTTP::Headers is not a Hash,
so X-ProxyMesh-IP was missing for that client.

Co-authored-by: ProxyMesh AI <proxymeshai@users.noreply.github.com>
Rewrite CONNECT bytes only while a patched connection is opening, and
leave the WebMock class swap in the specs. HTTP.rb client options are
passed through instead of dropped.

Co-authored-by: ProxyMesh AI <proxymeshai@users.noreply.github.com>
@proxymesh
proxymesh force-pushed the cursor/fix-connect-adapters-8740 branch from 45fc194 to 7f0dbbe Compare November 13, 2026 02:50
@proxymesh
proxymesh merged commit cc0bf06 into main Nov 13, 2026
4 checks passed
@proxymesh
proxymesh deleted the cursor/fix-connect-adapters-8740 branch November 13, 2026 02:52
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.

3 participants