curl 0.4 bugfix release

January 11, 2015

This week curl version 0.4 appeared on CRAN. This release fixes a memory bug that was introduced in the previous version, and which could under some circumstances crash your R session. The new version is well tested and super stable. If you are using this package, updating is highly recommended.

What is curl again?

From the manual

The curl() function provides a drop-in replacement for base url() with better performance and support for http 2.0, ssl (https://, ftps://), gzip, deflate and other libcurl goodies. This interface is implemented using the RConnection API in order to support incremental processing of both binary and text streams.

Some examples from the help page illustrating https, gzip, redirects and other stuff that base url doesn’t do well:


# Read from a connection
con <- curl("")

# HTTP error
curl("", "r")

# Follow redirects

# Error after redirect
curl("", "r")

# Auto decompress Accept-Encoding: gzip / deflate (rfc2616 #14.3)


The advantage of curl over RCurl and httr is that the connection interface allows for streaming. For example you can use readLines to download and process data line-by-line:

con <- curl("", open = "r")
readLines(con, n = 3)
readLines(con, n = 3)
readLines(con, n = 3)

We can combine this with stream_in from jsonlite to stream-parse sizable datasets:

con <- gzcon(curl(""))
nycflights <- stream_in(con)