Advertisement
grepwood

Untitled

Nov 16th, 2015
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.19 KB | None | 0 0
  1. irb(main):001:0> require 'net/http'
  2. => true
  3. irb(main):002:0> proxy_uri = URI('http://10.159.32.155:8080')
  4. => #<URI::HTTP http://10.159.32.155:8080>
  5. 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')
  6. => #<URI::HTTPS https://repo1.maven.org/maven2/com/facebook/presto/presto-server/0.117/presto-server-0.117.tar.gz.sha1>
  7. irb(main):004:0> http = Net::HTTP.new(uri.path)
  8. => #<Net::HTTP /maven2/com/facebook/presto/presto-server/0.117/presto-server-0.117.tar.gz.sha1:80 open=false>
  9. irb(main):005:0> if uri.scheme == 'https'
  10. irb(main):006:1>   puts "watch out we got a badass here"
  11. irb(main):007:1>   http.use_ssl = true
  12. irb(main):008:1> end
  13. watch out we got a badass here
  14. => true
  15. irb(main):009:0> proxy = Net::HTTP::Proxy(proxy_uri.host, proxy_uri.port)
  16. => #<Class:0x00000002a5ae18>
  17. irb(main):010:0> http = proxy.start(uri.host, :use_ssl => true)
  18. => #<#<Class:0x00000002a5ae18> repo1.maven.org:443 open=true>
  19. irb(main):011:0> resp = http.get(uri.path)
  20. => #<Net::HTTPOK 200 OK readbody=true>
  21. irb(main):012:0> puts resp.code
  22. 200
  23. => nil
  24. irb(main):013:0> puts resp.body
  25. dcadf9c04e2fd83e64a9801d48c84694a0f6d189
  26. => nil
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement