downloadBinFile=function(url, file) {
## Courtesy of @antonio on stackoverflow
##  http://stackoverflow.com/a/15543569/1492421
    library('RCurl')
    if (!identical(length(url), length(file)))
      stop ("'url' and 'file' must have same length")

    f = CFILE(file, mode="wb")
    a = curlPerform(url = url, writedata = f@ref, noprogress=FALSE)

    close(f)
    return(a)
}


source.url <- function(...) {
 # load package
 require(RCurl)

 urls <- list(...)
 eval(parse(text=getURL(urls, followlocation=TRUE, cainfo=system.file("CurlSSL", "cacert.pem", package="RCurl"))),
      envir=parent.frame(1))
}

getUserAgent <- function(pkgName="R", major=R.Version()$major, minor=R.Version()$minor) {
  sprintf("%s/%s.%s", pkgName, major, minor)
}

addOtherInputParamsFromHTML <- function(html, params_user=c(), showWarnings=TRUE, justValidators=FALSE) {
  ## Returns the input params as a name-value list

  ## First, extract all <input ... > lines from the HTML and parse it
  DT.inputs <-  extractInputAttrsFromHTML(html=html, output="DT", showWarnings=FALSE)
  params_server <- as.list(DT.inputs[!is.na(value), setNames(nm=name, obj=value)])

  if (justValidators)
    params_server <- params_server[grepl("^__", names(params_server))]

  ## Combine the two groups of params then confirm list is complete and unique
  params <- c(params_user, params_server)

  ## Confirm parameters are unique (no dups) and complete (nothing missing)
  if (showWarnings) {
    if (anyDuplicated(names(params)))
      warning("Internal Error: There are duplicate names in the params.\n Namely: ", params[names(params)[duplicated(names(params))]])
    if (!justValidators && length(wh.missing <- setdiff(DT.inputs$name, names(params))))
      warning("Internal Error: Some input values are not being submitted with the html form.\n Namely: ", wh.missing)
  }

  return(params)
}