Module: Multipartable
- Included in:
- Net::HTTP::Post::Multipart, Net::HTTP::Put::Multipart
- Defined in:
- lib/multipartable.rb
Constant Summary collapse
- DEFAULT_BOUNDARY =
"-----------RubyMultipartPost"
Instance Method Summary collapse
Instance Method Details
#initialize(path, params, headers = {}, boundary = DEFAULT_BOUNDARY) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'lib/multipartable.rb', line 4 def initialize(path, params, headers={}, boundary = DEFAULT_BOUNDARY) super(path, headers) parts = params.map {|k,v| Parts::Part.new(boundary, k, v)} parts << Parts::EpiloguePart.new(boundary) ios = parts.map{|p| p.to_io } self.set_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 |