Crate tokio_curl [] [src]

A Future interface on top of libcurl

This crate provides a futures-based interface to the libcurl HTTP library. Building on top of the curl crate on, this allows using a battle-tested C library for sending HTTP requests in an asynchronous fashion.


extern crate curl;
extern crate futures;
extern crate tokio_core;
extern crate tokio_curl;

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

use curl::easy::Easy;
use futures::Future;
use tokio_core::reactor::Core;
use tokio_curl::Session;

fn main() {
    // Create an event loop that we'll run on, as well as an HTTP `Session`
    // which we'll be routing all requests through.
    let mut lp = Core::new().unwrap();
    let session = Session::new(lp.handle());

    // Prepare the HTTP request to be sent.
    let mut req = Easy::new();
    req.write_function(|data| {

    // Once we've got our session, issue an HTTP request to download the
    // rust-lang home page
    let request = session.perform(req);

    // Execute the request, and print the response code as well as the error
    // that happened (if any).
    let mut req =;
    println!("{:?}", req.response_code());

Platform support

This crate works on both Unix and Windows, but note that it will not scale well on Windows. Unfortunately the implementation (seemingly from libcurl) relies on select, which does not scale very far on Windows.



A future returned from the Session::perform method.


Error returned by the future returned from perform.


A shared cache for HTTP requests to pool data such as TCP connections between.