Skip to content

Commit 818bfb4

Browse files
authored
Merge pull request #2 from rpolley/add-ruby-examples
add ruby example
2 parents f0eb2bf + 64b15ae commit 818bfb4

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

ruby/requests_proxy.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
require 'net/http'
2+
require 'uri'
3+
4+
uri = URI('http://example.com')
5+
proxy_options = {
6+
p_addr: 'PROXYHOST',
7+
p_port: PORT,
8+
# username/password are optional if you have IP authentication
9+
p_user: 'USERNAME',
10+
p_pass: 'PASSWORD',
11+
}
12+
13+
Net::HTTP.start(uri.host, uri.port, **proxy_options) do |http|
14+
request = Net::HTTP::Get.new uri
15+
response = http.request request
16+
end

0 commit comments

Comments
 (0)