class HTTP::FormData::Multipart
‘multipart/form-data` form data.
def self.generate_boundary
-
(String)
-
def self.generate_boundary ("-" * 21) << SecureRandom.hex(21) end
def content_type
-
(String)
-
def content_type "multipart/form-data; boundary=#{@boundary}" end
def glue
-
(String)
-
def glue @glue ||= "--#{@boundary}#{CRLF}" end
def initialize(data, boundary: self.class.generate_boundary)
-
data
(#to_h, Hash
) -- form data key-value Hash
def initialize(data, boundary: self.class.generate_boundary) parts = Param.coerce FormData.ensure_hash data @boundary = boundary.to_s.freeze @io = CompositeIO.new [*parts.flat_map { |part| [glue, part] }, tail] end
def tail
-
(String)
-
def tail @tail ||= "--#{@boundary}--#{CRLF}" end