@@ -31,6 +31,23 @@ def initialize(cache = nil)
31
31
cache . extend ( PuppetForgeServer ::Utils ::FilteringInspecter )
32
32
@log = PuppetForgeServer ::Logger . get
33
33
@cache = cache
34
+ @uri_options = {
35
+ 'User-Agent' => "Puppet-Forge-Server/#{ PuppetForgeServer ::VERSION } " ,
36
+ :allow_redirections => :safe ,
37
+ }
38
+ # OpenURI does not work with http_proxy=http://username:password@proxyserver:port/
39
+ # so split the proxy_url and feed it basic authentication.
40
+ if ENV . has_key? ( 'http_proxy' )
41
+ proxy = URI . parse ( ENV [ 'http_proxy' ] )
42
+ if proxy . userinfo != nil
43
+ @uri_options [ :proxy_http_basic_authentication ] = [
44
+ "#{ proxy . scheme } ://#{ proxy . host } :#{ proxy . port } " ,
45
+ proxy . userinfo . split ( ':' ) [ 0 ] ,
46
+ proxy . userinfo . split ( ':' ) [ 1 ]
47
+ ]
48
+ end
49
+ end
50
+
34
51
end
35
52
36
53
def post_file ( url , file_hash , options = { } )
@@ -69,7 +86,7 @@ def open_uri(url)
69
86
contents = @cache . fetch ( url ) do
70
87
tmpfile = ::Timeout . timeout ( 10 ) do
71
88
PuppetForgeServer ::Logger . get . debug "Fetching data for url: #{ url } from remote server"
72
- open ( url , 'User-Agent' => "Puppet-Forge-Server/ #{ PuppetForgeServer :: VERSION } " , :allow_redirections => :safe )
89
+ open ( url , @uri_options )
73
90
end
74
91
contents = tmpfile . read
75
92
tmpfile . close
0 commit comments