Crate curl

source ·
Expand description

Rust bindings to the libcurl C library

This crate contains bindings for an HTTP/HTTPS client which is powered by libcurl, the same library behind the curl command line tool. The API currently closely matches that of libcurl itself, except that a Rustic layer of safety is applied on top.

§The “Easy” API

The easiest way to send a request is to use the Easy api which corresponds to CURL in libcurl. This handle supports a wide variety of options and can be used to make a single blocking request in a thread. Callbacks can be specified to deal with data as it arrives and a handle can be reused to cache connections and such.

use std::io::{stdout, Write};

use curl::easy::Easy;

// Write the contents of to stdout
let mut easy = Easy::new();
easy.write_function(|data| {

§What about multiple concurrent HTTP requests?

One option you have currently is to send multiple requests in multiple threads, but otherwise libcurl has a “multi” interface for doing this operation. Initial bindings of this interface can be found in the multi module, but feedback is welcome!

§Where does libcurl come from?

This crate links to the curl-sys crate which is in turn responsible for acquiring and linking to the libcurl library. Currently this crate will build libcurl from source if one is not already detected on the system.

There is a large number of releases for libcurl, all with different sets of capabilities. Robust programs may wish to inspect Version::get() to test what features are implemented in the linked build of libcurl at runtime.


The underlying libcurl library must be initialized before use and has certain requirements on how this is done. Check the documentation for init for more details.


  • Bindings to the “easy” libcurl API.
  • Multi - initiating multiple requests simultaneously


  • An error returned from various “easy” operations.
  • An error from “form add” operations.
  • An error from “multi” operations.
  • An iterator over the list of protocols a version supports.
  • An error returned from “share” operations.
  • Version information about libcurl and the capabilities that it supports.


  • Initializes the underlying libcurl library.