Skip to content

Commit 836a05d

Browse files
committed
parser: use URI#open instead of URI.open
Signed-off-by: Shizuo Fujita <[email protected]>
1 parent 1fa4f94 commit 836a05d

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/fluent/config/parser.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,17 @@ def process_include(attrs, elems, uri, allow_include = true)
9292
else
9393
basepath = '/'
9494
fname = path
95-
require 'open-uri'
96-
URI.open(uri) {|f|
95+
parser_proc = ->(f) {
9796
Parser.new(basepath, f.each_line, fname).parse!(allow_include, nil, attrs, elems)
9897
}
98+
99+
case u.scheme
100+
when 'http', 'https', 'ftp'
101+
require 'open-uri'
102+
u.open { |f| parser_proc.call(f) }
103+
else
104+
File.open(u.path) { |f| parser_proc.call(f) }
105+
end
99106
end
100107

101108
rescue SystemCallError => e
@@ -104,4 +111,3 @@ def process_include(attrs, elems, uri, allow_include = true)
104111
end
105112
end
106113
end
107-

0 commit comments

Comments
 (0)