Method: HTTP::Chainable#proxy

Defined in:
lib/http-proxy/chainable.rb

#proxy(anonymous = true, &block) ⇒ Object

Choose a proxy to send HTTP request

Parameters:

  • anonymous (Boolean) (defaults to: true)

    Using anonymous proxy or not



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/http-proxy/chainable.rb', line 9

def proxy(anonymous = true, &block)
  if anonymous
    p = ProxyPool.get_high_anonymous_proxy
  elsif block_given?
    p = ProxyPool.get(&block)
  else
    p = ProxyPool.get
  end

  via(p['host'], p['port'])
end