#rest

requests

Rust HTTP client API styled after awesome Python requests - [WORK IN PROGRESS]

30 releases

Uses old Rust 2015

0.0.30 Apr 9, 2017
0.0.27 Feb 7, 2017
0.0.25 Nov 12, 2016
0.0.22 Jul 24, 2016
0.0.4 Jan 25, 2016

#573 in HTTP client

27 downloads per month
Used in 3 crates

MIT license

8KB
181 lines

requests-rs

Rust HTTP client library styled after awesome Python requests

Build status

branch status
master Build Status
develop Build Status

Travis

Building on OSX 10.11+

export OPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include
cargo clean
cargo build

lib.rs:

requests - HTTP client library with simple API.
If you have used Python requests module you will find the API familiar.

Quick Start

extern crate requests;
use requests::ToJson;

fn main() {
    let response = requests::get("http://httpbin.org/get").unwrap();
    assert_eq!(response.url(), "http://httpbin.org/get");
    assert_eq!(response.reason(), "OK");
    assert_eq!(response.status_code(), requests::StatusCode::Ok);

    let data = response.json().unwrap();
    assert_eq!(data["url"], "http://httpbin.org/get");
    assert_eq!(data["headers"]["Host"], "httpbin.org");
    assert_eq!(data["headers"]["User-Agent"],
               concat!("requests-rs/", env!("CARGO_PKG_VERSION")));
}

Dependencies

~4–12MB
~150K SLoC