File tree Expand file tree Collapse file tree
lib/puppet/parser/functions Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,21 +28,22 @@ module Puppet::Parser::Functions
2828 require 'open-uri'
2929 begin
3030 if args [ 0 ] . start_with? ( 'http://' , 'https://' )
31- username = ''
32- password = ''
31+ http_options = { }
3332 if ( match = args [ 0 ] . match ( %r{(http\: //|https\: //)(.*):(.*)@(.*)} ) )
3433 # If URL is in the format of https://username:password@example.local/my_hash.yaml
3534 protocol , username , password , path = match . captures
3635 url = "#{ protocol } #{ path } "
36+ http_options [ :http_basic_authentication ] = [ username , password ]
3737 elsif ( match = args [ 0 ] . match ( %r{(http\: \/ \/ |https\: \/ \/ )(.*)@(.*)} ) )
3838 # If URL is in the format of https://username@example.local/my_hash.yaml
3939 protocol , username , path = match . captures
4040 url = "#{ protocol } #{ path } "
41+ http_options [ :http_basic_authentication ] = [ username , password ]
4142 else
4243 url = args [ 0 ]
4344 end
4445 begin
45- contents = OpenURI . open_uri ( url , http_basic_authentication : [ username , password ] )
46+ contents = OpenURI . open_uri ( url , ** http_options )
4647 rescue OpenURI ::HTTPError => err
4748 res = err . io
4849 warning ( "Can't load '#{ url } ' HTTP Error Code: '#{ res . status [ 0 ] } '" )
You can’t perform that action at this time.
0 commit comments