30个版本
使用旧的Rust 2015
0.0.30 | 2017年4月9日 |
---|---|
0.0.27 | 2017年2月7日 |
0.0.25 | 2016年11月12日 |
0.0.22 | 2016年7月24日 |
0.0.4 | 2016年1月25日 |
#440 在 HTTP客户端
62 每月下载量
在 3 crates 中使用
8KB
181 行
requests-rs
Rust HTTP客户端库,仿照强大的Python requests
构建状态
分支 | 状态 |
---|---|
master | |
develop |
在OSX 10.11+上构建
export OPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include
cargo clean
cargo build
lib.rs
:
requests - 简单API的HTTP客户端库。
如果你使用过Python requests模块,你会觉得API很熟悉。
快速入门
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")));
}
依赖关系
~4–12MB
~159K SLoC