Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- irb(main):001:0> require 'net/http'
- => true
- irb(main):002:0> proxy_uri = URI('http://10.159.32.155:8080')
- => #<URI::HTTP http://10.159.32.155:8080>
- irb(main):003:0> uri = URI('https://repo1.maven.org/maven2/com/facebook/presto/presto-server/0.117/presto-server-0.117.tar.gz.sha1')
- => #<URI::HTTPS https://repo1.maven.org/maven2/com/facebook/presto/presto-server/0.117/presto-server-0.117.tar.gz.sha1>
- irb(main):004:0> http = Net::HTTP.new(uri.path)
- => #<Net::HTTP /maven2/com/facebook/presto/presto-server/0.117/presto-server-0.117.tar.gz.sha1:80 open=false>
- irb(main):005:0> if uri.scheme == 'https'
- irb(main):006:1> puts "watch out we got a badass here"
- irb(main):007:1> http.use_ssl = true
- irb(main):008:1> end
- watch out we got a badass here
- => true
- irb(main):009:0> proxy = Net::HTTP::Proxy(proxy_uri.host, proxy_uri.port)
- => #<Class:0x00000002a5ae18>
- irb(main):010:0> http = proxy.start(uri.host, :use_ssl => true)
- => #<#<Class:0x00000002a5ae18> repo1.maven.org:443 open=true>
- irb(main):011:0> resp = http.get(uri.path)
- => #<Net::HTTPOK 200 OK readbody=true>
- irb(main):012:0> puts resp.code
- 200
- => nil
- irb(main):013:0> puts resp.body
- dcadf9c04e2fd83e64a9801d48c84694a0f6d189
- => nil
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement