# NOT RUN {
  u = "http://www.omegahat.net/RCurl/data.gz"
if(url.exists(u)) withAutoprint({
  content = getBinaryURL(u)
  if (getRversion() >= "4") withAutoprint({
    x <- memDecompress(content, asChar = TRUE)
    read.csv(textConnection(x))
  }) else withAutoprint({
     tmp = tempfile()
     writeBin(content, con = tmp)
     read.csv(gzfile(tmp))
     unlink(tmp)
  })
   # Working from the Content-Type in the header of the HTTP response.
  h  = basicTextGatherer()
  content = getBinaryURL(u, .opts = list(headerfunction = h$update))
  header = parseHTTPHeader(h$value())
  type = strsplit(header["Content-Type"], "/")[[1]]
  if(type[2] %in% c("x-gzip", "gzip")) {
  if (getRversion() >= "4") {
     cat(memDecompress(content, asChar = TRUE))
  } else {
    tmp = tempfile()
    writeBin(content, con = tmp)
    writeLines(readLines(gzfile(tmp)))
    unlink(tmp)
    }
  }
})
# }
Run the code above in your browser using DataLab