-
-
Save Lysxia/ed129e39e4cb730c9458408690187abf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate futures; | |
extern crate reqwest; | |
#[macro_use] extern crate log; | |
extern crate env_logger; | |
use std::fmt; | |
use log::{debug}; | |
use reqwest::async as reqwest_async; | |
use futures::{Async, Future, Poll, Stream}; | |
fn main() { | |
let mut l = tokio::runtime::Runtime::new().unwrap(); | |
let c = reqwest_async::Client::new(); | |
let uri = "https://nest.pijul.com/pijul_org/pijul/.pijul/patches/".to_string() | |
+ "8UhQnQGqctQvoavXPHF544iRf47dSMEPFCWx3vBEwq4Egav6vrzoPwqQm6cHBTbwCH4XWidGEYAvkD2xgzsNd7Pf" | |
+ ".gz"; | |
let uri : reqwest::Url = uri.parse().unwrap(); | |
env_logger::init(); | |
for i in 0..600 { | |
debug!("{:?}", i); | |
let res = l.block_on( | |
c.get(uri.clone()).send() | |
.and_then(move |resp| { | |
debug!("{:?} / {:?} bytes", resp.status(), resp.content_length()); | |
if resp.status() == reqwest::StatusCode::OK { | |
// let res : Vec<u8> = Vec::new(); | |
futures::future::Either::A( | |
resp.into_body() | |
.fold((), |(), x| { | |
// res.extend(x.iter()); | |
futures::future::ok::<_, reqwest::Error>(()) | |
}) | |
) | |
} else { | |
futures::future::Either::B(futures::future::ok(())) | |
} | |
}) | |
// c.execute(reqwest::async::Request::new(reqwest::Method::GET, uri.clone())) | |
).unwrap(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment