Hyper पर एक नज़र डालें:
यह कुछ ऐसा दिखाई देगा।
एक जीईटी अनुरोध भेजना उतना आसान है जितना।
let client = Client::new();
let res = client.get("http://example.domain").send().unwrap();
assert_eq!(res.status, hyper::Ok);
आप documentation में और उदाहरण पा सकते हैं।
संपादित: ऐसा लगता है कि Hyper थोड़ा और अधिक जटिल हो गया है क्योंकि वे Tokio उपयोग करने के लिए शुरू कर दिया। यहां अद्यतन संस्करण है।
extern crate futures;
extern crate hyper;
extern crate tokio_core;
use std::io::{self, Write};
use futures::{Future, Stream};
use hyper::Client;
use tokio_core::reactor::Core;
fn main() {
let mut core = Core::new().unwrap();
let client = Client::new(&core.handle());
let uri = "http://httpbin.org/ip".parse().unwrap();
let work =
client.get(uri).and_then(|res| {
println!("Response: {}", res.status());
res.body().for_each(|chunk| {
io::stdout()
.write_all(&chunk)
.map_err(From::from)
})
});
core.run(work).unwrap();
}
और यहां आवश्यक निर्भरताएं हैं। निर्दिष्ट के रूप में in the Rust Cookbook
[dependencies]
futures = "0.1"
hyper = "0.11"
tokio-core = "0.1"
क्या आपने http crates के लिए googling की कोशिश की है? उदाहरण के लिए, [यह आपके लिए काम कर सकता है] (https://github.com/alexcrichton/curl-rust)। – user4815162342
इस तरह का सवाल स्टैक ओवरफ़्लो पर ऑफ-विषय है, इसलिए यह बंद हो जाएगा। यदि आपको तब तक आपका जवाब नहीं मिला है, तो मैं आपको जंग टैग विकी [सहायता प्राप्त करना] (http://stackoverflow.com/tags/rust/info) अनुभाग देखने के लिए आमंत्रित करता हूं जो ओपन-एंडेड प्रश्नों के लिए अन्य स्थानों का विवरण देता है। –