module HTTMultiParty::Multipartable
Constants
- DEFAULT_BOUNDARY
Public Instance Methods
body=(value)
click to toggle source
# File lib/httmultiparty/multipartable.rb, line 9 def body=(value) @body_parts = Array(value).map { |(k, v)| Parts::Part.new(boundary, k, v) } @body_parts << Parts::EpiloguePart.new(boundary) set_headers_for_body end
boundary()
click to toggle source
# File lib/httmultiparty/multipartable.rb, line 15 def boundary DEFAULT_BOUNDARY end
initialize_http_header(initheader)
click to toggle source
prevent reinitialization of headers
Calls superclass method
# File lib/httmultiparty/multipartable.rb, line 4 def initialize_http_header(initheader) super set_headers_for_body end
Private Instance Methods
set_headers_for_body()
click to toggle source
# File lib/httmultiparty/multipartable.rb, line 21 def set_headers_for_body if defined?(@body_parts) && @body_parts set_content_type('multipart/form-data', 'boundary' => boundary) self.content_length = @body_parts.inject(0) { |sum, i| sum + i.length } self.body_stream = CompositeReadIO.new(*@body_parts.map(&:to_io)) end end