Rust bindings to libcurl
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 467 commits behind alexcrichton:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


libcurl bindings for Rust. This project is in active development and could (will probably) break API compatibility at any time.

Quick Start

extern crate curl;

use curl::http;

pub fn main() {
  let resp = http::handle()

  println!("code={}; headers={:?}; body={:?}",
    resp.get_code(), resp.get_headers(), resp.get_body());

Response header names are automatically lower cased.

Post / Put requests

Both of these methods expect that a request body is provided. A request body can be a &[u8], &str, or &Reader. For example:

let resp = http::handle()
  .post("", "this is the body")

Custom headers

Custom headers can be specified as part of the request:

  .header("Authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==")

Keep alive

The handle can be re-used across multiple requests. Curl will attempt to keep the connections alive.

let handle = http::handle();

let resp1 = handle.get("").exec().unwrap();
let resp2 = handle.get("").exec().unwrap();

Version Support

The bindings have been developed using curl version 7.24.0. They should work with any newer version of curl and possibly with older versions, but this has not been tested.