From 7a1111f6f2807d3347b19b9520fa376583073869 Mon Sep 17 00:00:00 2001 From: armandfardeau Date: Fri, 30 Jun 2023 19:50:54 +0200 Subject: [PATCH] Allow to pass GET parameters --- .ruby-version | 1 - lib/tor/http.rb | 2 +- spec/tor/http_spec.rb | 4 ++-- 3 files changed, 3 insertions(+), 4 deletions(-) delete mode 100644 .ruby-version diff --git a/.ruby-version b/.ruby-version deleted file mode 100644 index 944880f..0000000 --- a/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -3.2.0 diff --git a/lib/tor/http.rb b/lib/tor/http.rb index 61c6437..d3ae295 100644 --- a/lib/tor/http.rb +++ b/lib/tor/http.rb @@ -46,7 +46,7 @@ def self.start_socks_proxy(start_params, &block) def self.get_with_socks_proxy(uri_or_host, host, port, path, max_redirects) start_params = start_parameters(uri_or_host, host, port) start_socks_proxy(start_params) do |http| - request = Net::HTTP::Get.new(path || uri_or_host.path) + request = Net::HTTP::Get.new(path || uri_or_host) Tor.configuration.headers.each do |header, value| request.delete(header) request.add_field(header, value) diff --git a/spec/tor/http_spec.rb b/spec/tor/http_spec.rb index dc5b682..91b90d4 100644 --- a/spec/tor/http_spec.rb +++ b/spec/tor/http_spec.rb @@ -15,7 +15,7 @@ context "with URI parameter" do %w[http https].each do |protocol| it "follows the #{protocol} redirects" do - stub_request(:get, "#{protocol}://google.com/").with( + stub_request(:get, "#{protocol}://google.com/?q=1234").with( headers: { "Accept" => "*/*", "Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3", @@ -23,7 +23,7 @@ } ).to_return(status: 200, body: "", headers: {}) - res = tor_http.get(URI("#{protocol}://google.com/")) + res = tor_http.get(URI("#{protocol}://google.com/?q=1234")) expect(res.code).to eq("200") end