Multipart::Post SourceMultipartPostPartsParamPart

class ParamPart

Represents a parametric part to be filled with given value.

Definitions

def initialize(boundary, name, value, headers = {})

Implementation

def initialize(boundary, name, value, headers = {})
  @part = build_part(boundary, name, value, headers)
  @io = StringIO.new(@part)
end

def build_part(boundary, name, value, headers = {})

Implementation

def build_part(boundary, name, value, headers = {})
  part = String.new
  part << "--#{boundary}\r\n"
  part << "Content-ID: #{headers["Content-ID"]}\r\n" if headers["Content-ID"]
  part << "Content-Disposition: form-data; name=\"#{name.to_s}\"\r\n"
  part << "Content-Type: #{headers["Content-Type"]}\r\n" if headers["Content-Type"]
  part << "\r\n"
  part << "#{value}\r\n"
end