Skip to content

Commit 72ab948

Browse files
authored
Merge pull request #1 from proxymesh/feature/net-http-connect-patch
Net::HTTP CONNECT patch and tests
2 parents 6cb78dc + 3f91f4f commit 72ab948

18 files changed

Lines changed: 943 additions & 1777 deletions

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/.bundle/
2+
/vendor/bundle/
3+
*.gem
4+
/pkg/
5+
/coverage/
6+
*.swp
7+
.env
8+
.ruby-version

DEFERRED.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Deferred / not fully supported
2+
3+
## Typhoeus / Ethon
4+
5+
**Status:** Not implemented in this gem.
6+
7+
[Ethon](https://github.com/typhoeus/ethon) does not expose `CURLOPT_PROXYHEADER` (or equivalent) in its `Ethon::Easy` option mapping as of ethon 0.18.x. Adding CONNECT response header capture would require Ethon/libcurl changes or a custom C extension.
8+
9+
**Workaround:** Use `Net::HTTP` + {RubyProxyHeaders::NetHTTP.patch!} or Faraday with `ruby_proxy_headers_net_http` adapter.
10+
11+
---
12+
13+
## Mechanize
14+
15+
**Status:** Not implemented.
16+
17+
[Mechanize](https://github.com/sparklemotion/mechanize) uses [net-http-persistent](https://github.com/drbrain/net-http-persistent), which maintains its own connection layer on top of `Net::HTTP`. Our prepend patch targets `Net::HTTP#connect` on instances Mechanize creates, but verifying header propagation and lifecycle across the persistent pool needs dedicated work.
18+
19+
**Workaround:** Use patched `Net::HTTP` or Faraday for fetches; use Mechanize only when custom CONNECT headers are not required.
20+
21+
---
22+
23+
## Excon — reading CONNECT response headers
24+
25+
**Status:** Sending extra CONNECT headers is supported upstream via `:ssl_proxy_headers`.
26+
27+
Excon’s public `Excon::Response` for the **origin** request does **not** include headers from the proxy’s `CONNECT` response (only the tunneled HTTPS response headers). Capturing `X-ProxyMesh-IP` from CONNECT would require patching Excon internals or a fork.
28+
29+
**Workaround:** Use Net::HTTP / Faraday integrations in this gem, which merge CONNECT headers into the client response where applicable.

Gemfile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,3 @@
33
source 'https://rubygems.org'
44

55
gemspec
6-
7-
group :development, :test do
8-
gem 'pry', '~> 0.14'
9-
gem 'yard', '~> 0.9'
10-
end

Gemfile.lock

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
PATH
2+
remote: .
3+
specs:
4+
ruby-proxy-headers (0.2.0)
5+
6+
GEM
7+
remote: https://rubygems.org/
8+
specs:
9+
addressable (2.8.9)
10+
public_suffix (>= 2.0.2, < 8.0)
11+
base64 (0.3.0)
12+
bigdecimal (4.0.1)
13+
connection_pool (3.0.2)
14+
csv (3.3.5)
15+
domain_name (0.6.20240107)
16+
ethon (0.18.0)
17+
ffi (>= 1.15.0)
18+
logger
19+
excon (1.4.2)
20+
logger
21+
faraday (2.14.1)
22+
faraday-net_http (>= 2.0, < 3.5)
23+
json
24+
logger
25+
faraday-net_http (3.4.2)
26+
net-http (~> 0.5)
27+
ffi (1.17.3-aarch64-linux-gnu)
28+
ffi (1.17.3-aarch64-linux-musl)
29+
ffi (1.17.3-arm-linux-gnu)
30+
ffi (1.17.3-arm-linux-musl)
31+
ffi (1.17.3-arm64-darwin)
32+
ffi (1.17.3-x86_64-darwin)
33+
ffi (1.17.3-x86_64-linux-gnu)
34+
ffi (1.17.3-x86_64-linux-musl)
35+
http-cookie (1.1.0)
36+
domain_name (~> 0.5)
37+
httparty (0.24.2)
38+
csv
39+
mini_mime (>= 1.0.0)
40+
multi_xml (>= 0.5.2)
41+
json (2.19.2)
42+
logger (1.7.0)
43+
mechanize (2.14.0)
44+
addressable (~> 2.8)
45+
base64
46+
domain_name (~> 0.5, >= 0.5.20190701)
47+
http-cookie (~> 1.0, >= 1.0.3)
48+
mime-types (~> 3.3)
49+
net-http-digest_auth (~> 1.4, >= 1.4.1)
50+
net-http-persistent (>= 2.5.2, < 5.0.dev)
51+
nkf
52+
nokogiri (~> 1.11, >= 1.11.2)
53+
rubyntlm (~> 0.6, >= 0.6.3)
54+
webrick (~> 1.7)
55+
webrobots (~> 0.1.2)
56+
mime-types (3.7.0)
57+
logger
58+
mime-types-data (~> 3.2025, >= 3.2025.0507)
59+
mime-types-data (3.2026.0317)
60+
mini_mime (1.1.5)
61+
multi_xml (0.8.1)
62+
bigdecimal (>= 3.1, < 5)
63+
net-http (0.9.1)
64+
uri (>= 0.11.1)
65+
net-http-digest_auth (1.4.1)
66+
net-http-persistent (4.0.8)
67+
connection_pool (>= 2.2.4, < 4)
68+
nkf (0.2.0)
69+
nokogiri (1.19.2-aarch64-linux-gnu)
70+
racc (~> 1.4)
71+
nokogiri (1.19.2-aarch64-linux-musl)
72+
racc (~> 1.4)
73+
nokogiri (1.19.2-arm-linux-gnu)
74+
racc (~> 1.4)
75+
nokogiri (1.19.2-arm-linux-musl)
76+
racc (~> 1.4)
77+
nokogiri (1.19.2-arm64-darwin)
78+
racc (~> 1.4)
79+
nokogiri (1.19.2-x86_64-darwin)
80+
racc (~> 1.4)
81+
nokogiri (1.19.2-x86_64-linux-gnu)
82+
racc (~> 1.4)
83+
nokogiri (1.19.2-x86_64-linux-musl)
84+
racc (~> 1.4)
85+
public_suffix (7.0.5)
86+
racc (1.8.1)
87+
rubyntlm (0.6.5)
88+
base64
89+
typhoeus (1.6.0)
90+
ethon (>= 0.18.0)
91+
uri (1.1.1)
92+
webrick (1.9.2)
93+
webrobots (0.1.2)
94+
95+
PLATFORMS
96+
aarch64-linux-gnu
97+
aarch64-linux-musl
98+
arm-linux-gnu
99+
arm-linux-musl
100+
arm64-darwin
101+
x86_64-darwin
102+
x86_64-linux-gnu
103+
x86_64-linux-musl
104+
105+
DEPENDENCIES
106+
bundler (>= 2.4)
107+
excon (~> 1.4)
108+
faraday (~> 2.14)
109+
faraday-net_http (~> 3.4)
110+
httparty (~> 0.24)
111+
mechanize (~> 2.14)
112+
ruby-proxy-headers!
113+
typhoeus (~> 1.6)
114+
115+
CHECKSUMS
116+
addressable (2.8.9) sha256=cc154fcbe689711808a43601dee7b980238ce54368d23e127421753e46895485
117+
base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
118+
bigdecimal (4.0.1) sha256=8b07d3d065a9f921c80ceaea7c9d4ae596697295b584c296fe599dd0ad01c4a7
119+
connection_pool (3.0.2) sha256=33fff5ba71a12d2aa26cb72b1db8bba2a1a01823559fb01d29eb74c286e62e0a
120+
csv (3.3.5) sha256=6e5134ac3383ef728b7f02725d9872934f523cb40b961479f69cf3afa6c8e73f
121+
domain_name (0.6.20240107) sha256=5f693b2215708476517479bf2b3802e49068ad82167bcd2286f899536a17d933
122+
ethon (0.18.0) sha256=b598afc9f30448cb068b850714b7d6948e941476095d04f90a4ac65b8d6efcb2
123+
excon (1.4.2) sha256=32d8d8eda619717d9b8043b4675e096fb5c2139b080e2ad3b267f88c545aaa35
124+
faraday (2.14.1) sha256=a43cceedc1e39d188f4d2cdd360a8aaa6a11da0c407052e426ba8d3fb42ef61c
125+
faraday-net_http (3.4.2) sha256=f147758260d3526939bf57ecf911682f94926a3666502e24c69992765875906c
126+
ffi (1.17.3-aarch64-linux-gnu) sha256=28ad573df26560f0aedd8a90c3371279a0b2bd0b4e834b16a2baa10bd7a97068
127+
ffi (1.17.3-aarch64-linux-musl) sha256=020b33b76775b1abacc3b7d86b287cef3251f66d747092deec592c7f5df764b2
128+
ffi (1.17.3-arm-linux-gnu) sha256=5bd4cea83b68b5ec0037f99c57d5ce2dd5aa438f35decc5ef68a7d085c785668
129+
ffi (1.17.3-arm-linux-musl) sha256=0d7626bb96265f9af78afa33e267d71cfef9d9a8eb8f5525344f8da6c7d76053
130+
ffi (1.17.3-arm64-darwin) sha256=0c690555d4cee17a7f07c04d59df39b2fba74ec440b19da1f685c6579bb0717f
131+
ffi (1.17.3-x86_64-darwin) sha256=1f211811eb5cfaa25998322cdd92ab104bfbd26d1c4c08471599c511f2c00bb5
132+
ffi (1.17.3-x86_64-linux-gnu) sha256=3746b01f677aae7b16dc1acb7cb3cc17b3e35bdae7676a3f568153fb0e2c887f
133+
ffi (1.17.3-x86_64-linux-musl) sha256=086b221c3a68320b7564066f46fed23449a44f7a1935f1fe5a245bd89d9aea56
134+
http-cookie (1.1.0) sha256=38a5e60d1527eebc396831b8c4b9455440509881219273a6c99943d29eadbb19
135+
httparty (0.24.2) sha256=8fca6a54aa0c4aa4303a0fd33e5e2156175d6a5334f714263b458abd7fda9c38
136+
json (2.19.2) sha256=e7e1bd318b2c37c4ceee2444841c86539bc462e81f40d134cf97826cb14e83cf
137+
logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
138+
mechanize (2.14.0) sha256=33e76b7639d0181a46eaf1136b05f0e9043dfc5fc4b1a7b9fd8ae8bd437dd5e4
139+
mime-types (3.7.0) sha256=dcebf61c246f08e15a4de34e386ebe8233791e868564a470c3fe77c00eed5e56
140+
mime-types-data (3.2026.0317) sha256=77f078a4d8631d52b842ba77099734b06eddb7ad339d792e746d2272b67e511b
141+
mini_mime (1.1.5) sha256=8681b7e2e4215f2a159f9400b5816d85e9d8c6c6b491e96a12797e798f8bccef
142+
multi_xml (0.8.1) sha256=addba0290bac34e9088bfe73dc4878530297a82a7bbd66cb44dcd0a4b86edf5a
143+
net-http (0.9.1) sha256=25ba0b67c63e89df626ed8fac771d0ad24ad151a858af2cc8e6a716ca4336996
144+
net-http-digest_auth (1.4.1) sha256=4b8ad50ed8d180a58db5d6c49449b987dd0466fe01e24037945bc007562a08db
145+
net-http-persistent (4.0.8) sha256=ef3de8319d691537b329053fae3a33195f8b070bbbfae8bf1a58c796081960e6
146+
nkf (0.2.0) sha256=fbc151bda025451f627fafdfcb3f4f13d0b22ae11f58c6d3a2939c76c5f5f126
147+
nokogiri (1.19.2-aarch64-linux-gnu) sha256=c34d5c8208025587554608e98fd88ab125b29c80f9352b821964e9a5d5cfbd19
148+
nokogiri (1.19.2-aarch64-linux-musl) sha256=7f6b4b0202d507326841a4f790294bf75098aef50c7173443812e3ac5cb06515
149+
nokogiri (1.19.2-arm-linux-gnu) sha256=b7fa1139016f3dc850bda1260988f0d749934a939d04ef2da13bec060d7d5081
150+
nokogiri (1.19.2-arm-linux-musl) sha256=61114d44f6742ff72194a1b3020967201e2eb982814778d130f6471c11f9828c
151+
nokogiri (1.19.2-arm64-darwin) sha256=58d8ea2e31a967b843b70487a44c14c8ba1866daa1b9da9be9dbdf1b43dee205
152+
nokogiri (1.19.2-x86_64-darwin) sha256=7d9af11fda72dfaa2961d8c4d5380ca0b51bc389dc5f8d4b859b9644f195e7a4
153+
nokogiri (1.19.2-x86_64-linux-gnu) sha256=fa8feca882b73e871a9845f3817a72e9734c8e974bdc4fbad6e4bc6e8076b94f
154+
nokogiri (1.19.2-x86_64-linux-musl) sha256=93128448e61a9383a30baef041bf1f5817e22f297a1d400521e90294445069a8
155+
public_suffix (7.0.5) sha256=1a8bb08f1bbea19228d3bed6e5ed908d1cb4f7c2726d18bd9cadf60bc676f623
156+
racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f
157+
ruby-proxy-headers (0.2.0)
158+
rubyntlm (0.6.5) sha256=47013402b99ae29ee93f930af51edaec8c6008556f4be25705a422b4430314f5
159+
typhoeus (1.6.0) sha256=bacc41c23e379547e29801dc235cd1699b70b955a1ba3d32b2b877aa844c331d
160+
uri (1.1.1) sha256=379fa58d27ffb1387eaada68c749d1426738bd0f654d812fcc07e7568f5c57c6
161+
webrick (1.9.2) sha256=beb4a15fc474defed24a3bda4ffd88a490d517c9e4e6118c3edce59e45864131
162+
webrobots (0.1.2) sha256=ebbcaa2cb4930fa1b83206f432c5cb64746507b2dcf50ea1301569a4d662cda6
163+
164+
BUNDLED WITH
165+
4.0.8

0 commit comments

Comments
 (0)