# Each of these examples can be done with getURLContent().
# These are here just to illustrate the dynamic reader.
if(url.exists("https://www.omegahat.net/Rcartogram/demo.jpg")) withAutoprint({
header = dynCurlReader()
curlPerform(url = "https://www.omegahat.net/Rcartogram/demo.jpg",
headerfunction = header$update, curl = header$curl())
class( header$value() )
length( header$value() )
})
if(url.exists("https://www.omegahat.net/dd.gz")) withAutoprint({
# gzip example.
header = dynCurlReader()
curlPerform(url = "https://www.omegahat.net/dd.gz",
headerfunction = header$update, curl = header$curl())
class( header$value() )
length( header$value() )
if (getRversion() >= "4")
cat(memDecompress(header$value(), asChar = TRUE))
## or cat(Rcompression::gunzip(header$value()))
})
# Character encoding example
if (FALSE) {
header = dynCurlReader()
curlPerform(url = "http://www.razorvine.net/test/utf8form/formaccepter.sn",
postfields = c(text = "ABC", outputencoding = "UTF-8"),
verbose = TRUE,
writefunction = header$update, curl = header$curl())
class( header$value() )
Encoding( header$value() )
}
Run the code above in your browser using DataLab