module Rack::Multipart

def build_multipart(params, first = true)

def build_multipart(params, first = true)
  Generator.new(params, first).dump
end

def extract_multipart(req, params = Rack::Utils.default_query_parser)

def extract_multipart(req, params = Rack::Utils.default_query_parser)
  io = req.get_header(RACK_INPUT)
  io.rewind
  content_length = req.content_length
  content_length = content_length.to_i if content_length
  tempfile = req.get_header(RACK_MULTIPART_TEMPFILE_FACTORY) || Parser::TEMPFILE_FACTORY
  bufsize = req.get_header(RACK_MULTIPART_BUFFER_SIZE) || Parser::BUFSIZE
  info = Parser.parse io, content_length, req.get_header('CONTENT_TYPE'), tempfile, bufsize, params
  req.set_header(RACK_TEMPFILES, info.tmp_files)
  info.params
end

def parse_multipart(env, params = Rack::Utils.default_query_parser)

def parse_multipart(env, params = Rack::Utils.default_query_parser)
  extract_multipart Rack::Request.new(env), params
end