Module: OpenURI

Defined in:
lib/dangerous_open_uri.rb

Class Method Summary collapse

Class Method Details

.open_http(buf, target, proxy, options) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/dangerous_open_uri.rb', line 8

def self.open_http(buf, target, proxy, options)
  if proxy
    proxy_uri, proxy_user, proxy_pass = proxy

    if proxy_uri.userinfo
      proxy_user = proxy_uri.user
      proxy_pass = proxy_uri.password
      proxy_uri.userinfo = ""
      proxy = [proxy_uri, proxy_user, proxy_pass]
    end
  end

  _target = target.dup

  if _target.userinfo
    options[:http_basic_authentication] = [_target.user, _target.password]
    _target.userinfo = ""
  end

  original_open_http(buf, _target, proxy, options)
end