class Fedora::Connection

def do_method(method, path, body = '', headers = {})

def do_method(method, path, body = '', headers = {})
  meth_map={:put=>Net::HTTP::Put::Multipart, :post=>Net::HTTP::Post::Multipart}
  raise "undefined method: #{method}" unless meth_map.has_key? method
  headers = build_request_headers(headers) 
  if body.respond_to?(:read)
    if body.respond_to?(:original_filename?)
      filename = File.basename(body.original_filename)
      io = UploadIO.new(body, mime_type,filename)
    elsif body.path
      filename = File.basename(body.path)
    else
      filename="NOFILE"
    end
    mime_types = MIME::Types.of(filename)
    mime_type ||= mime_types.empty? ? "application/octet-stream" : mime_types.first.content_type
    io = nil
    if body.is_a?(File)
      io = UploadIO.new(body.path,mime_type)
    else
      io =UploadIO.new(body, mime_type, filename)
    end
    req = meth_map[method].new(path, {:file=>io}, headers)
    multipart_request(req)
  else
    request(method, path, body.to_s, headers)
  end
end