curl 0.4 bugfix release

[This article was first published on OpenCPU, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

opencpu logo

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)

To leave a comment for the author, please follow the link and comment on their blog: OpenCPU. offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)