Skip to content

Commit

Permalink
makes the request accepting a socks address as proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
mdidato committed Jul 15, 2015
1 parent 9048e1e commit f0cfd69
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/httpi/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def cookie_store

# Expects a +url+, validates its validity and returns a +URI+ object.
def normalize_url!(url)
raise ArgumentError, "Invalid URL: #{url}" unless url.to_s =~ /^http/
raise ArgumentError, "Invalid URL: #{url}" unless url.to_s =~ /^http|socks/
url.kind_of?(URI) ? url : URI(url)
end

Expand Down
5 changes: 5 additions & 0 deletions spec/httpi/request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@
expect(request.proxy).to eq(URI("http://proxy.example.com"))
end

it 'also accepts the socks URL to use as a String' do
request.proxy ="socks://socks.example.com"
expect(request.proxy).to eq(URI("socks://socks.example.com"))
end

it "also accepts a URI object" do
request.proxy = URI("http://proxy.example.com")
expect(request.proxy).to eq(URI("http://proxy.example.com"))
Expand Down

0 comments on commit f0cfd69

Please sign in to comment.