Module: Katello::Util::HttpProxy

Included in:
Pulp3::Repository, RepoDiscovery, Resources::Candlepin::UpstreamCandlepinResource
Defined in:
app/lib/katello/util/http_proxy.rb

Instance Method Summary collapse

Instance Method Details

#proxyObject



20
21
22
# File 'app/lib/katello/util/http_proxy.rb', line 20

def proxy
  ::HttpProxy.default_global_content_proxy
end

#proxy_hostObject



24
25
26
# File 'app/lib/katello/util/http_proxy.rb', line 24

def proxy_host
  URI(proxy.url).host
end

#proxy_portObject



32
33
34
# File 'app/lib/katello/util/http_proxy.rb', line 32

def proxy_port
  URI(proxy.url).port
end

#proxy_schemeObject



28
29
30
# File 'app/lib/katello/util/http_proxy.rb', line 28

def proxy_scheme
  URI(proxy.url).scheme
end

#proxy_uriObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/lib/katello/util/http_proxy.rb', line 4

def proxy_uri
  #Reset the scheme to proxy(s) based on http or https to handle cgi unescaping in rest-client
  if proxy
    scheme = 'proxy' if proxy_scheme == 'http'
    scheme = 'proxys' if proxy_scheme == 'https'

    uri = URI("#{scheme}://#{proxy_host}:#{proxy_port}")
    if proxy && proxy.username.present?
      uri.user = CGI.escape(proxy.username)
      uri.password = CGI.escape(proxy.password)
    end

    uri.to_s
  end
end