10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/puppet/feature/multipartable.rb', line 10
def initialize(path, params, ={}, boundary = DEFAULT_BOUNDARY)
= .clone = .delete(:parts) || {}
super(path, )
parts = params.map do |k,v|
case v
when Array
v.map {|item| Parts::Part.new(boundary, k, item, [k]) }
else
Parts::Part.new(boundary, k, v, [k])
end
end.flatten
parts << Parts::EpiloguePart.new(boundary)
ios = parts.map {|p| p.to_io }
self.set_content_type(["Content-Type"] || "multipart/form-data",
{ "boundary" => boundary })
self.content_length = parts.inject(0) {|sum,i| sum + i.length }
self.body_stream = CompositeReadIO.new(*ios)
end
|