-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow core classes to be extended
- Loading branch information
Showing
9 changed files
with
158 additions
and
48 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
name: connect-proxy | ||
version: 1.4.1 | ||
version: 2.0.0 | ||
license: MIT | ||
crystal: ">= 0.36.1" | ||
|
||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
require "spec" | ||
require "../src/connect-proxy" | ||
require "../src/connect-proxy/ext/*" | ||
require "./proxy_server" | ||
|
||
describe "proxy ext" do | ||
it "connect to a website and get a response" do | ||
host = URI.parse("https://github.com/") | ||
response = ::HTTP::Client.new(host) do |client| | ||
client.exec("GET", "/") | ||
end | ||
response.success?.should eq(true) | ||
end | ||
|
||
it "connect to a website and get a response using explicit proxy" do | ||
host = URI.parse("https://github.com/") | ||
expected_count = CONNECTION_COUNT[0] + 1 | ||
client = ::HTTP::Client.new(host, ignore_env: true) | ||
proxy = ConnectProxy.new("localhost", 22222) | ||
client.set_proxy(proxy) | ||
response = client.exec("GET", "/") | ||
client.close | ||
response.success?.should eq(true) | ||
expected_count.should eq(CONNECTION_COUNT[0]) | ||
end | ||
|
||
it "connect to a website with CRL checks disabled" do | ||
ConnectProxy.verify_tls = true | ||
ConnectProxy.disable_crl_checks = true | ||
|
||
host = URI.parse("https://github.com/") | ||
client = ::HTTP::Client.new(host, ignore_env: true) | ||
proxy = ConnectProxy.new("localhost", 22222) | ||
client.set_proxy(proxy) | ||
response = client.exec("GET", "/") | ||
client.close | ||
response.success?.should eq(true) | ||
end | ||
|
||
it "connect to a website with TLS disabled" do | ||
ConnectProxy.verify_tls = false | ||
|
||
host = URI.parse("https://github.com/") | ||
client = ::HTTP::Client.new(host, ignore_env: true) | ||
proxy = ConnectProxy.new("localhost", 22222) | ||
client.set_proxy(proxy) | ||
response = client.exec("GET", "/") | ||
client.close | ||
response.success?.should eq(true) | ||
end | ||
|
||
it "connect to a websocket using explicit proxy" do | ||
received = "" | ||
|
||
expected_count = CONNECTION_COUNT[0] + 1 | ||
|
||
host = URI.parse("wss://ws.postman-echo.com/raw") | ||
proxy = ConnectProxy.new("localhost", 22222) | ||
|
||
ws = ::HTTP::WebSocket.new(host, proxy: proxy) | ||
ws.on_message do |msg| | ||
puts msg | ||
received = msg | ||
ws.close | ||
end | ||
ws.send "test" | ||
ws.run | ||
|
||
received.should eq("test") | ||
expected_count.should eq(CONNECTION_COUNT[0]) | ||
end | ||
end |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require "../../connect-proxy" | ||
|
||
class ::HTTP::Client | ||
include ConnectProxy::ProxyHTTP | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require "../../connect-proxy" | ||
|
||
class ::HTTP::WebSocket | ||
include ConnectProxy::ProxyWebSocket | ||
end |
This file contains 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
This file contains 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